react.dev
react.dev copied to clipboard
[Suggestion]: Section from useContext might not be entirely accurate
Summary
There is a paragraph about re-rendering of children when parent re-renders which doesn't seem to be accurate, see below.
Page
https://react.dev/reference/react/useContext#optimizing-re-renders-when-passing-objects-and-functions
Details
Here: https://react.dev/reference/react/useContext#optimizing-re-renders-when-passing-objects-and-functions, it says in the bottom of the section:
As a result of this change, even if MyApp needs to re-render, the components calling useContext(AuthContext) won’t need to re-render unless currentUser has changed.
This is not entirely true. because if MyApp re-renders, all of its children (including those consuming the context) will re-render by default, regardless if currentUser has changed or not.