score:0
I faced a similar problem. My solution was to set a timeout before adding new value to the state and clear it before.
Probably the problem is because setState() is usually asynchronous, which means that at the time you wanna see changes in the state, it's not updated yet.
const watchNewVideo = (video) => {
setTopVideo(null);
setTimeout(() => {
setTopVideo(video);
}, 10);
};
Source: stackoverflow.com
Related Query
- React Video Component not updating when state changes
- React component not updating when store state has changed
- Updating the react component state when a global variable changes
- React Component not updated when state changes
- HighCharts not updating when the state changes in React
- React jsx array component does not re-render when state changes
- Input element's value in react component is not getting re-rendered when the state changes
- React component not updating on changes to map (data structure) in redux state store
- react is not re-rendering component inside array.map, when state of array changes
- Updating react component when redux state changes
- Unrouted React component not updating when Route changes
- React component not re-rendering when state changes
- React component is not getting updated when state changes into the redux
- react className not updating when state changes
- Value of state within React context not updating when used in another component
- React Component does not re rendering when updating an object in state hooks
- React does not re-render component when the state changes
- Child component is not updating when parent state changes
- React component not updating when redux state is updating
- react prop not updating at correct time when passed from parent component state
- Component not updating when mapped state changes
- changes not showing up in state when using TinyMCE in my React Component
- When state changes the right component is not getting displayed in React
- react state is not updating when it's value changes
- React child component not rerendering when updating parent component state
- React component not updating when state is changed
- State not updating when using React state hook within setInterval
- React Child Component Not Updating After Parent State Change
- React shouldComponentUpdate() is called even when props or state for that component did not change
- Why is my react component not updating with state updates?
More Query from same tag
- Unit testing image tag with image object
- Adding custom Typescript type declaration for a node module in Create React App
- useState can't seem to properly map array
- How to make image size dependent on the parents font size
- Typescript error with jsonwebtoken decode
- Uncaught TypeError: Cannot read property 'props' of null
- ReactJS render element by ref
- Importing Public Folder Images In Src Css Files In Reactjs
- Fetch error - Missing \"data\" payload in the request body
- Property Does Not Exist on Type 'Never' Typescript/React
- React Conditional Rendering with states
- styled-components - IE11 support - Invalid characters
- ReactJS variable change isn't rendering element
- in react, how to subscribe to document mousemove?
- Why my books not arranged in correct shelves (React-Redux)?
- Not able to upload Image with ImageField in EDIT mode for react-admin
- How to install Material-UI Docs WITHOUT installing material-ui?
- My tests isn't working with react-testing-library with typescript
- Refactor nested async callback within react’s componentDidMount() using an external file
- React + redux app deployed on heroku but backend/api not working
- Ref issue and Calling custom hook after useEffect
- React hooks state Management
- Stuck with the installation of React.js
- How to add a shared layout when using NextJS and Auth0?
- Can I prevent some route to be rendered on server side in React App
- How to make a button inside of the anchor tag clickable in React?
- How to change individual elements within array using useState
- babel core 7.4.4, using all polyfills by default
- Adding Properties boxes on the spot inside a form tag
- Getting comp-id from div class in grid