Rules
no-use-context
Full Name in eslint-plugin-react-x
Full Name in @eslint-react/eslint-plugin
Features
🔍
🔄
Presets
core
recommended
recommended-typescript
recommended-type-checked
What it does
Disallows using React.useContext
.
In React 19, use
is preferred over useContext
because it is more flexible.
In addition, it is recommended to enable the naming-convention/context-name
rule to enforce consistent naming conventions for contexts.
An unsafe codemod is available for this rule.
Examples
Failing
Passing
Implementation
Further Reading
See Also
no-context-provider
Disallows using<Context.Provider>
.no-forward-ref
Disallows usingReact.forwardRef
.