react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

[Suggestion]: Section from useContext might not be entirely accurate

Open gmoniava opened this issue 1 year ago • 0 comments
trafficstars

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.

gmoniava avatar Apr 08 '24 19:04 gmoniava