You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
useEffect doesn't appear to work as a "one time effect". I'd like to use it to send a message to a web worker when a component loads, but nothing happens until the component unmounts. I'd use useAff, but because it sets state, I'm getting into a nasty infinite loop in my particular case. If you need an example, I can put one together, but perhaps I just need clarification on how to do a "one time efect"
Thanks!
The text was updated successfully, but these errors were encountered:
The effect will clean up and rerun any time the provided key changes. Try a constant valve as the key, such as unit. Another option is to construct your effect such that rerunning it isn’t a problem. That isn’t always possible though.
ah it does work. It was not clear to me that I was returning the cleanup effect from the function, so everything was wrapped up in that return value. I've made a PR (#8) with some docs clarifying this if anyone else runs into the same issue.
useEffect
doesn't appear to work as a "one time effect". I'd like to use it to send a message to a web worker when a component loads, but nothing happens until the component unmounts. I'd useuseAff
, but because it sets state, I'm getting into a nasty infinite loop in my particular case. If you need an example, I can put one together, but perhaps I just need clarification on how to do a "one time efect"Thanks!
The text was updated successfully, but these errors were encountered: