Thanks Rudy, I believe you may have got me out of a jam with your suggestion of putting the if statement in useEffect. In my use case i need to watch for a change in the url as my app gets a redirect back from an api with a token.
( when path !== '/' means I have received a token from the api)
So now I can check it but only do something if I have the token, before I was getting a bit confused about needing useMemo or useRef.
Surprised I didn't think of your solution, perhaps I had it in my head that you shouldn't use conditionals inside useEffect.
So thanks again, and thanks SavagePixie for your post.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks Rudy, I believe you may have got me out of a jam with your suggestion of putting the if statement in useEffect. In my use case i need to watch for a change in the url as my app gets a redirect back from an api with a token.
( when path !== '/' means I have received a token from the api)
So now I can check it but only do something if I have the token, before I was getting a bit confused about needing useMemo or useRef.
Surprised I didn't think of your solution, perhaps I had it in my head that you shouldn't use conditionals inside useEffect.
So thanks again, and thanks SavagePixie for your post.