-
Notifications
You must be signed in to change notification settings - Fork 14
Hometask5 #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Hometask5 #74
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { ADD_COMMENT } from '../constants' | ||
|
|
||
| function generateId() { | ||
| return Math.random().toString(16).slice(2) | ||
| } | ||
|
|
||
| export default store => next => action => { | ||
| const { type, payload } = action | ||
|
|
||
| switch (type) { | ||
| case ADD_COMMENT: { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. через мидлвары будет проходить каждый экшин, они должны быть максимально общими, завязывать на конкретные экшины - не лучшее решение |
||
| action.payload = { | ||
| ...payload, | ||
| comment: {...payload.comment, id: generateId()} | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return next(action) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import {createStore, applyMiddleware, compose} from 'redux' | ||
| import rootReducer from '../reducer' | ||
| import logger from '../middlewares/logger' | ||
| import uniqueIds from '../middlewares/uniqueIds' | ||
|
|
||
| const composeEnhancers = | ||
| typeof window === 'object' && | ||
|
|
@@ -10,7 +11,7 @@ const composeEnhancers = | |
| }) : compose | ||
|
|
||
| const enhancer = composeEnhancers( | ||
| applyMiddleware(logger) | ||
| applyMiddleware(logger, uniqueIds) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. лучше логгер в конце ставить |
||
| ) | ||
| const store = createStore(rootReducer, enhancer) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше селектор, который достанет из в виде массива