DEV Community

Discussion on: Use previous value through a React hook

Collapse
 
snigo profile image
Igor Snitkin

The fact that useEffect is called after render (return) doesn't mean anything to your Application component, I hope you realise this. Any component update, apart from loading, will update wasLoading value. And then when loading will eventually change, the fact that useEffect is called after render will play cruel joke with you, because your if statement will never fire. Hmm...

Collapse
 
snigo profile image
Igor Snitkin

...though I guess in this will still work based on the fact that useEffect in custom hook will always be invoked before the one in Application, just in time switching values back. OK