DEV Community

Discussion on: Frustrations with React Hooks

Collapse
 
devdufutur profile image
Rudy Nappée

You can add a parameter which can be a boolean "condition". It can act as a trigger when it become true.

Then you can add a
if (condition) {}
around the xhr and add the same condition in the dependency array

Then you have a declarative trigger and you don't need to move the useXXX call anymore