That's what I meant to say
When I was a junior react developer, I always told to use callback whenever the new value is referencing the old one.
And indeed, doing simple setState it doesn't matter
But as the app grows, there are 2 cases that may cause the setState incorrect
state update really fast
multiple setState is called in different places
But I still tend to use callback whenever possible, because it's hard to justify when is okay to use the value straight away when the code is complex
Also when you are doing a large refactor, you can't rethink to make sure every single setState is safe
After the release of React hooks, I see more ppl write code that has a lot of side effect, useEffect everywhere, thus I think its more important to enforce this rule, otherwise ppl may fix a lot of silly bugs
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.
That's what I meant to say
When I was a junior react developer, I always told to use callback whenever the new value is referencing the old one.
And indeed, doing simple setState it doesn't matter
But as the app grows, there are 2 cases that may cause the setState incorrect
But I still tend to use callback whenever possible, because it's hard to justify when is okay to use the value straight away when the code is complex
Also when you are doing a large refactor, you can't rethink to make sure every single setState is safe
After the release of React hooks, I see more ppl write code that has a lot of side effect, useEffect everywhere, thus I think its more important to enforce this rule, otherwise ppl may fix a lot of silly bugs