3 ms·
How can you "fetch something when your state change ?". It's the main use case for useEffect.
by revskill 3y ago
How can you "fetch something when your state change ?". It's the main use case for useEffect.
- deleted 3y ago[deleted]
- scotty79 3y agoYou can just trigger fetch in the function that does the state change.
- shortcake27 3y agoAgreed, this is the correct approach. Overusing effects makes control flow difficult to understand and has many unintended consequences. The misuse of effects is so widespread the React team had to address it with Strict mode in React 18.