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

[Bug]: False positive for destructuring-assignment with useContext #3520

Closed
2 tasks done
haack opened this issue Jan 12, 2023 · 0 comments
Closed
2 tasks done

[Bug]: False positive for destructuring-assignment with useContext #3520

haack opened this issue Jan 12, 2023 · 0 comments
Labels

Comments

@haack
Copy link

haack commented Jan 12, 2023

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

This library is amazing 🙏

Just wanted to share that in latest (7.32.0) I'm getting a linting error for a non-destructured assign from useContext. Please correct me if I'm wrong but I don't this this is valid in every case because the context value might be a nullable object.

Expected Behavior

Here's a simple example of what I think should be a valid case:

import { useContext } from 'react';

const MyComponent = (props) => {
  const foo = useContext(aContext);
  return <div>{foo?.test}</div>
};

eslint-plugin-react version

v7.32.0

eslint version

v8.31.0

node version

v16.14.2

@haack haack added the bug label Jan 12, 2023
@ljharb ljharb closed this as completed in 74a9522 Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant