Closed mcordova47 closed 2 years ago
Another go at a re-runnable useEffect hook. Still feels a bit questionable, though. Basically, the idea is:
useEffect
deps
Use componentDidUpdate and then check if the dependencies changed and, if so, run the effect again.
componentDidUpdate
I also rearranged the way the name gets generated to fix the name generation for useState and useEffect.
useState
just make your own React class and FFI it into PureScript (similar to what browserEvents does)
browserEvents
Ahhh, good idea!
Another go at a re-runnable
useEffect
hook. Still feels a bit questionable, though. Basically, the idea is:Old Idea
Cache thedeps
when calling the hook (because the cached component can’t check them directly from its closure, as the value will be staleStore thedeps
in the component’s stateConstantly update the componentWhen thedeps
are different from the cacheddeps
, update the state and re-run the effectNew Idea
Use
componentDidUpdate
and then check if the dependencies changed and, if so, run the effect again.I also rearranged the way the name gets generated to fix the name generation for
useState
anduseEffect
.