#Do you need if (typeof window!=='undefined') in a useeffect?

3 messages · Page 1 of 1 (latest)

snow maple
#

I've seen people stack both when doing things that will only work on the client (ie accessing localStorage) but I thought useEffect only runs on client anyway so is there a need to use both?

#

or can i just use the useEffect and then not worry about being on the server

civic lava
#

useEffect only runs in the client, checking if window exists is redundant