score:0
Accepted answer
the bug is caused by mutating state in the reducer
// this is mutating the prepinfos property in state
return state.prepinfos.map(prepinfo => {
if (prepinfo.id == data.id) {
return {...prepinfo, [data.name]: data.value}
};
return prepinfo;
});
// this is creating and returning a new obj for state and the prepinfos key in state
return {
...state,
prepinfos: state.prepinfos.map(prepinfo => {
if (prepinfo.id == data.id) {
return {...prepinfo, [data.name]: data.value}
};
return prepinfo;
}
Source: stackoverflow.com
Related Query
- Change in state not being rendered with object.map
- ReactJs setState result not being rendered with map
- Router state not being persisted in react-native with redux
- Why is the DOM not updating with state change in ReactJS?
- React Child with useEffect() not updating on Parent State Change
- React not updating state with setState with Array of object
- Component not updating on Map (dictionary) state change using hooks
- Map of React Components not re rendering on State Change
- Calling setState with nested object does not update state correctly
- params object (API key) not being sent with axios.create
- React Component not updating with state change
- Making an Axios call within a forEach function to ammend an object is not being recognized in the render despite being in the state
- react.js - Deep Object in state with async data does not work
- state do not change with useContext
- React - handle change of input with state rendered by iteration through an array
- React component does not update with the change in redux state
- Accessing the previous state of a functional component with state being an object
- Why is my React component not re-rendering upon state change with Date?
- Component with setinterval not updating on context state change
- React JS - Change parent state on child click, map not iterable
- Specific targeting of CSS classes with Styled Components not being rendered - React
- reactjs state is not being updated with button click using useState hook
- React change component state in a fetch, leads to Object not valid as a React child error
- React components not rendered on url change with React Router
- With click being handled in `addEventListener`, the change of state on click happens only once. [React Hooks]
- I am not being able to change the state of my state objects in React.js
- Can not change state of object
- I have a multidimensional object with several layers of nested arrays and I'm trying to map through all of them in one go but not sure how to
- React Router -- history push state not refreshing with new state object
- autoHideDuration not work with change on state
More Query from same tag
- Exception while invoking method 'users.insert' Error: Match error: Expected array, got "admin" in field [0].roles Reading project metadata
- Gatsby Source Contentful 4.x - Rich Text - changes to JSON
- Jest + React: IntersectionObserver mock not working?
- react-hook-form controller with validation based on value
- ReactJs fixed-data-table: data.getObjectAt is not a function
- Create a dropdown animation in react
- Form.Control <Options></Options>, how to select from a dropdown populated through JSON
- Can't verify email and password from Firebase
- Constructor(props) and super(props) VS constructor() and super() in React
- How can I render my popup component over a Container or Div instead of below to it
- React.js: how to create search filter?
- Image resizing in React Native
- How can I give ToggleButton Border Colors in material ui?
- Is it possible to add show all pages in the rows per page?
- How can I make conditional Header with React
- How to change a key?
- ReactJS: How to make selection by default checked in Material Table by default?
- Trying to display JSON by sections in React JS
- How to display values of the 2 inputs in the above field?
- Too big file size of Reactjs application after building via browserify + reactify
- Reduce code redundancy with multiple buttons using React
- Next.js: getServerSideProps and or getInitialProps affecting the page loads
- Getting TypeError: Cannot read property 'map' of undefined error
- onClick dont call the function
- Test url params in react-testing-library without react-router
- How to get array in class component to another file in react?
- ReactJS token base post?
- How to set focus to an element after browser search bar closed?
- .map() function does not render out message in react.js
- nested array if value is equal add object to array in state