Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Prefer React.use over React.useContext #930

Closed
kachkaev opened this issue Jan 27, 2025 · 0 comments
Closed

[feat] Prefer React.use over React.useContext #930

kachkaev opened this issue Jan 27, 2025 · 0 comments
Labels
React 19 Status: Released The issue has been released Type: New Rule Introduce a new rule

Comments

@kachkaev
Copy link

kachkaev commented Jan 27, 2025

Describe the problem

React 19 allows both useContext(MyContext) and use(MyContext) (announcement | docs). Unlike useContext, use can be used conditionally.

Describe the solution you'd like

I’d like to maintain consistency in the codebase and ban useContext because it does a subset of what use can do. It’d be great to have a new auto-fixable rule, e.g. @eslint-react/prefer-use or @eslint-react/no-use-context. This rule would be somewhat similar to @eslint-react/no-forward-ref / @eslint-react/no-context-provider which help to embrace new React 19 features.

Alternatives considered

It is possible to ban useContext via no-restricted-syntax but that’s harder to configure and there is no auto-fix.

Additional context

No response

@Rel1cx Rel1cx added the Type: New Rule Introduce a new rule label Jan 27, 2025
@Rel1cx Rel1cx added React 19 Status: In Progress The issue is currently being worked on labels Jan 27, 2025
@Rel1cx Rel1cx closed this as completed in 0d60aac Jan 28, 2025
@Rel1cx Rel1cx added Status: Released The issue has been released and removed Status: In Progress The issue is currently being worked on labels Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React 19 Status: Released The issue has been released Type: New Rule Introduce a new rule
Projects
None yet
Development

No branches or pull requests

2 participants