score:2
Accepted answer
Try changing your reducer to be:
case "ADD_REVIEW_ITEM":
return state.map((data) => {
if (data.id === action.payload.selectedDataId) {
return {
...data,
listOfReview: [...data.listOfReview, action.payload.newReview]
};
}
return data;
});
Currently, you are mutating the state variable and pushing in an array which can lead to side-effect.
Source: stackoverflow.com
Related Query
- Data get updated twice on button onClick event
- Get object data and target element from onClick event in react js
- reactjs - how to get data from a child component into onclick of a button passed in props?
- How to get the TextField value with onclick button event React Material UI
- Got all button updated in reactjs onclick event
- How to pass variable to graphql from method when onClick with button and get it's return data back?
- How to get the data of id in json using onClick event
- Get row data based of onclick event react, using html tables in react
- React Js Handling event button on a column to get row using onClick
- React TypeScript get Data Attribute From Click Event
- When to use inline function on button onClick event - Javascript/React.js
- How to get React Table Row Data Onclick
- Is it possible for button onClick to fire twice before being disabled since setState is asynchronous?
- Creating a Custom Button in React Typescript and add onClick Event
- How to get updated data from apollo cache
- how to use react devtools to get function tied to an onClick event listener
- React: passing mapped data from button onclick to display on another component
- Reactjs onClick event how to select a specific button from a list
- How to get onClick Event for a Label in ChartJS and React?
- onClick event - change data for a single row in react table
- React/Next.js how to get other Element event target value on button click
- How to check/uncheck a checkbox with onClick event on a button in React.js?
- React - how can I get updated data to show in my table?
- Pass onClick event to Button Component in React
- ReactJS Button not calling the onClick event
- CreateContext hook is not passed data to child component on button click event
- React onClick event working on twice clicks when clicking again
- Change html attribute value does not have data with onclick event using react
- What element can I use to wrap a Typography component so that it accepts an onClick event listener without using button
- How do you get a button in DIV not call the <div> click event
More Query from same tag
- reactJS hooks asx Changing the style parameters for a div when it is clicked
- How to keep track of the state in functional component in Reactjs?
- Pass state between Parent and Child components in React/Typescript
- CORS policy blocking HTTP delete method
- react_dom_development is undefined in Deno React project
- Change a single parameter in URL
- React Issue - Child state changes the parent's state
- How to make unique date for every element from array?
- CSS - Dynamically Remove Font Descender
- React +getting value from queryString
- Confirm remote sync - Firebase Realtime Database w/ ReactJS+Redux+Saga
- Set background color of Material UI Snackbar
- Can a mutable object in Redux store that is only mutated outside of Redux cause unexpected side effects?
- Typescript setState with computed property names
- Next.js | Is there any way to render an .xml file?
- Cannot initialize redux-form with values comming from Axios
- How to get ref from a React 16 portal?
- SPA with Deepstream.io HTTP authentication for a login page
- React ES6 onSubmit() does not work
- How do I make this table sortable?
- Multiple Registration Form with redux and react
- React Context error on rendering
- How to spy on a class property arrow function using Jest
- How can I display a set of array on click of a button from it's child component using React
- Mock service worker is unable to intercept network request
- React Importing a component folder
- How to get password field value in react's material-ui
- How do make an api fetch request on button click Reactjs?
- javascript csv header for all nested objects
- I'm using semantic ui react Card. I'm trying to create Memory game. is there a way i can have flip animation for the card.