Skip to content

Feature Request: Add Warning when consuming a context whose provider is not mounted #20003

@jonrose-dev

Description

@jonrose-dev

React allows you to consume a context, even if it's Provider is not mounted. Imagine a scenario where you are building a new context, and forget to add the Provider. When you consume it with either useContext or the Consumer component, React will run without issue, but your code won't work as expected. This has led to hours of lost time debugging the wrong problem. Adding a warning that a context is being consumed that does not have its Provider mounted, would help to reduce the time spent debugging this issue.

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