Let's say you have a useState which returns a setter that we named setValue. If we call setValue outside of any function in our component, it would cause a re-render issue.
useState
setValue
const App = () => { const [value, setValue] = useState('') setValue('value') return <p>{value}</p> }
Another way that would cause this is if two useEffect depend on a value that the other updates.
useEffect
const [value1, setValue1] = useState('') const [value2, setValue2] = useState('') useEffect(() => { setValue1('value1') }, [value2]) useEffect(() => { setValue2('value2') }, [value1])
For more information, you can look at Rules of Hooks
Thanks, It really helps me a great deal. Appreciate you
Thanks, Karl This really helps me a great deal. Appreciate your help
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
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.
Let's say you have a
useState
which returns a setter that we namedsetValue
. If we callsetValue
outside of any function in our component, it would cause a re-render issue.Another way that would cause this is if two
useEffect
depend on a value that the other updates.For more information, you can look at Rules of Hooks
Thanks,
It really helps me a great deal.
Appreciate you
Thanks, Karl
This really helps me a great deal.
Appreciate your help