Yes, it will run on the first render. It seems a bit odd, but that is how it works. useEffect has to have an initial check, otherwise, how would it know if the variable changed or not?
To your second question, the effect will run, regardless if it was the cause of the rerender. useEffect checks on every render, regardless of the cause.
So an effect runs after everyrender if its dependencies requires so, ie. changed.
I sometimes think guides and docs should be a bit succinct. It is difficult to remember, spot,and find a valueable info in a corner of 5 mins read page.
A gotcha about dependency change is whereas the primitives are regarded not changed after set to same value the arrays and objects are regarded as changed after set to same value, naturally.
Also
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.
Yes, it will run on the first render. It seems a bit odd, but that is how it works. useEffect has to have an initial check, otherwise, how would it know if the variable changed or not?
To your second question, the effect will run, regardless if it was the cause of the rerender. useEffect checks on every render, regardless of the cause.
So an effect runs after every render if its dependencies requires so, ie. changed.
I sometimes think guides and docs should be a bit succinct. It is difficult to remember, spot,and find a valueable info in a corner of 5 mins read page.
A gotcha about dependency change is whereas the primitives are regarded not changed after set to same value the arrays and objects are regarded as changed after set to same value, naturally.
Also