dispatch
and setState
has a stable function identityReact guarantees that
dispatch
function identity is stable and won’t change on re-renders. This is why it’s safe to omit from theuseEffect
oruseCallback
dependency list.
This is also true for setState
.
https://reactjs.org/docs/hooks-faq.html#how-to-avoid-passing-callbacks-down