There is only one case where you should be fetching inside of useEffect, and that is with an empty dependency array to get data on first render. Pretty simple and easy to wrap your head around.
Everything else is triggered by event handlers. I work on a 70Loc react app and useEffect is used maybe once outside of this context. You really don't need it.
And I don't know what you mean by "listening to browser events" with useEffect. You really just need to use onClick and onChange.
You also don't need it to set state, you need calculated constant assignments.
Everything else is triggered by event handlers. I work on a 70Loc react app and useEffect is used maybe once outside of this context. You really don't need it.
And I don't know what you mean by "listening to browser events" with useEffect. You really just need to use onClick and onChange.
You also don't need it to set state, you need calculated constant assignments.