-
Notifications
You must be signed in to change notification settings - Fork 50.6k
Open
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug
Description
Hi there!
When updating to v7 of eslint-plugin-react-hooks, I'm getting an error that I haven't been getting on v5, and I believe it's a false positive.
This is my functional component:
function App() {
const groupRefs = {
group1: React.useRef<ComboBoxItemGroupDomRef>(null),
group2: React.useRef<ComboBoxItemGroupDomRef>(null),
};
// const group1Ref = React.useRef<ComboBoxItemGroupDomRef>(null);
// const group2Ref = React.useRef<ComboBoxItemGroupDomRef>(null);
return (
<ComboBox>
<ComboBoxItemGroup
ref={groupRefs.group1}
// ref={group1Ref}
headerText="Group 1"
>
<ComboBoxItem text="Item 1" />
</ComboBoxItemGroup>
<ComboBoxItemGroup
ref={groupRefs.group2}
// ref={group2Ref}
headerText="Group 2"
>
<ComboBoxItem text="Item 2" />
</ComboBoxItemGroup>
</ComboBox>
);
}I'm keeping a list of refs for each group, and I'm passing each one into the group element.
This gives me the following error:
I think the rule mistakenly interprets groupRefs.group2 as referencing ref.current, which is not the case. If I don't collect all refs in an object but create an individual variable for each, I don't get an error.
Steps to reproduce:
- Open this sandbox.
- Download it:
- Run
npm install, open in vscode. - You should get the error I screenshotted above.
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug