score:2
issue
looks like a state mutation in cardhandler
childhandler( update ) {
const {questions} = this.state;
let tempqs = questions; // <-- saved current state ref to tempqs
...
tempqs[temp[0]-1].question = temp1[1]; // <-- mutated state ref
tempqs[temp1[0]-1].question = temp[1]; // <-- mutated state ref
this.setstate({questions : tempqs},console.log(questions)); // <-- saved state ref
}
solution
shallow copy questions
into new array reference to update. this should allow react's state/props reference test to detect that state is a new object and rerender.
const {questions} = this.state;
let tempqs = [...questions]; // <-- spread existing array into new array
Source: stackoverflow.com
Related Query
- Table Component is not re-rendered after state update
- How to update React component after changing state through redux?
- How to test state update and component rerender after async call in react
- How does React update a component and its children after a state change?
- Reactjs update state after call component in functional component
- React doesn't update component after state changes
- react router v6 won't switch to Home Page after Login Page: Warning: Can't perform a React state update on an unmounted component
- Ract functional component doesn't update after state change
- Warning: Can't perform a React state update on an unmounted component after update context and redirect to another page
- How to call method in child component only once after parent state update
- Component List don't update state after deleting one item
- Can't get React component to update after setting state after Axios call
- How to update items in a component after state changes
- React useEffect doesn't reload my component after state update
- React update state of component after search through object
- React + Redux - Component doesn't update after state change
- React - Update state in class component based on text inputted by user after button click
- Update Redux after Component State change
- What react lifecycle component to use to update state after an axios post
- Cannot get component to update after state is updated
- How to update a child component state after an ajax call
- reactjs custom component input value doesnt update with state change
- Update State component after fetch Redux
- How to properly update state of component after promise inside promise call?
- ReactJS: how to immediately update component after changing state
- Reactjs - Update state of parent after obtaining calculated value from another component function
- component doesn't update after state update
- State of React child doesn't update after updating parent component
- How to update state of parent component after the server is updated in child component?
- React does not re-render component after state update
More Query from same tag
- I want to call a function inside a const with React, but React is not correctly show the function
- Navigate through pages using Redux and React-router
- Need Reactjs help on how to properly pass this function from the parent to child button component
- Cannot access props in method reactjs
- How to get multiple refs with array in React and useRef hook?
- React Hook useEffect has a missing dependency: 'context'. Either include it or remove the dependency array
- Change width of dropdown according to screen resolution
- How to add dynamically created link in React
- ReactJS - issue with rendering the proper component
- How to make MathJax faster?
- Could not resolve dependency: reactjs "npm install" on MacOS
- Reactjs state not updating
- react apollo - clear data object before refetch
- I am getting an error when using react and redux to get values via my database
- Testing component function in React with Enzyme and Jest
- React How to change view after click on button
- How to switch subcomponent after render depend on state?
- Why store event.target in a variable?
- How can I make an API call that depends on a value which is set by another call?
- Geeting dropdown options, with suggestions on top
- Warning: _renderNewRootComponent(): Render methods should be a pure function of props and state;
- Delay a push to a page on success
- How to use data from a callback function in the render method in a react class
- React-Router-Dom Link changes position of my button
- Webpack change url in css files
- Adding and removing class from list using Reactjs
- React - is it bad practice to pass up a callback?
- Why graphQLErrors are always empty in react components?
- Jest not preprocessing my JSX
- React useState hook is running indefinitely - infinite loop