3 ms·
I really do find the idea that we’ve pushed everything into the render cycle and then provided means to filter out the running of said thing quite weird. I’ve s
by andy_ppp 4y ago
I really do find the idea that we’ve pushed everything into the render cycle and then provided means to filter out the running of said thing quite weird. I’ve started using zustand and init functions to set things up out of the rendering loop and I almost never have a useEffect that isn’t wrapped in another hook to name it (especially as is often the case my use effect is doing something like “useStartLeaderboard” which only triggers under quite complicated state setups). They are adding an even more magical hook (another special case) called “use” for dealing with promises.
I really don’t like the use of a closure to manage if useEffect triggers and generally prefer code that is explicit. I suppose I could mitigate that a bit by naming the dependency array something like:
const depsRenderOnInitOnly = [];
useEffect(() =>{}, depsRenderOnInitOnly);
Generally I love React but these are my main concerns right now. First class support for promises + asynchrony/await will be great, I just wish it wasn’t another thing hacked on top of hooks and the render/diffing loop.