3 ms·
This isn’t quite true. If your effect depends on state, that state must be included as a dependency. This is easy to miss, so you install an eslint plugin to w
by shortcake27 3y ago
This isn’t quite true. If your effect depends on state, that state must be included as a dependency.
This is easy to miss, so you install an eslint plugin to warn you about missing dependencies.
This causes the opposite problem - adding dependencies unnecessarily to silence the warning. Then you need to ensure those dependencies are stable to avoid running the hook on every render. Or ignore the warning with a comment, and you’re back to square one.
It’s all too easy to write an effect that either doesn’t run when it should, or runs when it shouldn’t. This is especially true for inexperienced developers.