eslint-plugin-react-hooks: allow OptionalMemberExpression in deps (#18819)#18820
eslint-plugin-react-hooks: allow OptionalMemberExpression in deps (#18819)#18820gaearon merged 4 commits intofacebook:masterfrom
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d48edf0:
|
Details of bundled changes.Comparing: 9751935...6398ed5 eslint-plugin-react-hooks
Size changes (experimental) |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 6398ed5:
|
Details of bundled changes.Comparing: 9751935...6398ed5 eslint-plugin-react-hooks
Size changes (stable) |
|
Thanks! |
|
EDIT: reported via #18926 @gaearon I believe this PR caused a regression. consider: const someContext = {
users: Math.random() > 0.5 ? [{name: 'test'}] : undefined,
};
const filteredUsers = useMemo(() => {
return someContext.users?.filter((u) => u.name.startsWith('a'));
}, [someContext.users]);New version of hook now tells us the dep should be |
Summary
Fixes issue #18819
Test Plan
Added test case, and verified the fix works in my own VS Code instance.