Hi! Good point on keeping their usages inside of useEffect.
Storing variables in useState will be fine most of the time, but if you're in a situation where you're concerned about unnecessary re-renders impacting performance, this can be a useful way of getting around that. A real use-case might be if you had some sort of isFetching or hasMounted boolean that you need to keep track of.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi! Good point on keeping their usages inside of
useEffect
.Storing variables in
useState
will be fine most of the time, but if you're in a situation where you're concerned about unnecessary re-renders impacting performance, this can be a useful way of getting around that. A real use-case might be if you had some sort ofisFetching
orhasMounted
boolean that you need to keep track of.