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);

};


Related Query

More Query from same tag