7 ms·
It only matters that the order not change dynamically between renders. This probably could have been avoided if react required a unique key per hook, but I thin
by chrisco255 4y ago
It only matters that the order not change dynamically between renders. This probably could have been avoided if react required a unique key per hook, but I think for brevity it's a decent trade-off.
- ghayes 4y agoFor the life of me, I can't understand why they didn't go the route of "add an id to your hook." It would solve one of the two big gripes people have with hooks.
- dragonwriter 4y agoids would be stuttering (especially for things like useMemo/useState), add a different source of error, and—if the goal was to make hooks compatible with flow control—probably create new categories of bugs that would be harder to catch in a linter or even with runtime checks like the existing “number of hooks cllaed changed” one. Adding visual noise to enable subtle bugs may not be a win.