You can use map
. Here is an example implementation:
case 'SOME_ACTION':
return {
...state,
contents: state.contents.map(
(content, i) => i === 1 ? {...content, text: action.payload}
: content
)
}
More Related Contents:
- Why do we need middleware for async flow in Redux?
- When to use ES6 class based React components vs. functional ES6 React components?
- Why is my onClick being called on render? – React.js
- Await is a reserved word error inside async function
- How to overcome the CORS issue in ReactJS
- Why use Redux over Facebook Flux? [closed]
- Understanding React-Redux and mapStateToProps()
- Is this the correct way to delete an item using redux?
- React: how to load and render external html file?
- Is store.dispatch in Redux synchronous or asynchronous
- Updating nested data in redux store
- Cleaner/shorter way to update nested state in Redux?
- How do I access store state in React Redux?
- Getting an error “A non-serializable value was detected in the state” when using redux toolkit – but NOT with normal redux
- redux fetch body is not use with no cors mode
- What’s the ‘@’ (at symbol) in the Redux @connect decorator?
- Read Store’s Initial State in Redux Reducer
- How to trigger off callback after updating state in Redux?
- Cannot update a component while rendering a different component warning
- Uncaught Invariant Violation: Too many re-renders. React limits the number of renders to prevent an infinite loop
- Use Object.assign or Spread Operator in React/Redux? Which is a better practise
- Pros/cons of using redux-saga with ES6 generators vs redux-thunk with ES2017 async/await
- having multiple instance of same reusable redux react components on the same page/route
- Global state in React Native
- Update single value in item array | react redux
- Redux Presentational Components Vs Container Component
- Component won’t update when a redux state change occurs
- React-Redux: Should all component states be kept in Redux Store
- Could not find “store” in either the context or props of “Connect(App)”
- How to get simple dispatch from this.props using connect w/ Redux?