Skip to content

[Suggestion]: Improve Context usage Troubleshooting section #7656

Open
@olhapi

Description

@olhapi

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions