As I know useEffect can be triggered by the following conditions
- dependencies change
- Route change
- Initial render
I have the following component, data is a complex object. When it is triggered by route change, the data prop has the cached value. Everything else such as state, ref get reset.
const App = memo(({ data }}) => {
useEffect(() => {
// if triggered by route change, do thing
}, [data]);
return (<div />)
});
What is the best way to distinguish if useEffect invoked by route change?