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

[Suggestion]: Improve Context usage Troubleshooting section

Open olhapi opened this issue 8 months ago • 0 comments

Summary

Yesterday I found out that independently wrapped components in Context doesn't share the same Context values. Instead each one has their own context values.

Page

https://react.dev/reference/react/useContext

Details

Now when I think about it that makes sense, but it took quite some time to realize where's the issue in a complext real world app where we render React components in different places of legacy code.

Would be great if we extend the Troubleshooting section of the Context docs to include this case.

Example: https://codesandbox.io/p/sandbox/reactcontext-issue-example-f48m4m

olhapi avatar Feb 27 '25 10:02 olhapi