Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Change one property
- ES6
- ```js
- return {
- ...state,
- [productId]: (state[productId] || 0) + 1
- }
- ```
- SI
- ```js
- return state.merge({
- [productId]: (state[productId] || 0) + 1
- })
- ```
- ## Change one prop of object in array
- ES6
- ```js
- case EDIT_TODO:
- return state.map(todo =>
- todo.id === action.id ?
- Object.assign({}, todo, { text: action.text }) :
- todo
- )
- ```
- SI
- ```js
- case EDIT_TODO:
- return state.map(todo =>
- todo.id === action.id ?
- todo.merge(text: action.text) :
- todo
- )
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement