4 ms·
I recommend you read the article again. Just because window.location changes outside scope doesn't mean that React would update the component when window.locati
by cush 4y ago
I recommend you read the article again. Just because window.location changes outside scope doesn't mean that React would update the component when window.location changes just because you put it in a dependency array.
This is because props or state didn't change and the parent didn't rerender.
UseEffect dependencies aren't observables. You'd need to wire up an event listener on unload, hashChange, etc
https://stackoverflow.com/questions/58442168/why-useeffect-doesnt-run-on-window-location-pathname-changes#58443076 https://stackoverflow.com/questions/58442168/why-useeffect-d...