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

eslint-plugin-react-hooks: allow OptionalMemberExpression in deps (#18819) #18820

Merged
merged 4 commits into from
May 5, 2020

Conversation

coolkev
Copy link
Contributor

@coolkev coolkev commented May 4, 2020

Summary

Fixes issue #18819

Test Plan

Added test case, and verified the fix works in my own VS Code instance.

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 4, 2020

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:

Sandbox Source
awesome-bush-t95yr Configuration

@sizebot
Copy link

sizebot commented May 4, 2020

Details of bundled changes.

Comparing: 9751935...6398ed5

eslint-plugin-react-hooks

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
eslint-plugin-react-hooks.development.js +0.4% +0.3% 81.74 KB 82.04 KB 18.69 KB 18.74 KB NODE_DEV
eslint-plugin-react-hooks.production.min.js 🔺+0.6% 🔺+0.2% 22.66 KB 22.8 KB 7.66 KB 7.67 KB NODE_PROD

Size changes (experimental)

Generated by 🚫 dangerJS against 6398ed5

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 4, 2020

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:

Sandbox Source
throbbing-dawn-edrmn Configuration

@sizebot
Copy link

sizebot commented May 4, 2020

Details of bundled changes.

Comparing: 9751935...6398ed5

eslint-plugin-react-hooks

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
eslint-plugin-react-hooks.production.min.js 🔺+0.6% 🔺+0.2% 22.65 KB 22.79 KB 7.65 KB 7.66 KB NODE_PROD
eslint-plugin-react-hooks.development.js +0.4% +0.3% 81.73 KB 82.03 KB 18.68 KB 18.74 KB NODE_DEV

Size changes (stable)

Generated by 🚫 dangerJS against 6398ed5

@gaearon gaearon merged commit 7992ca1 into facebook:master May 5, 2020
@gaearon
Copy link
Collaborator

gaearon commented May 5, 2020

Thanks!

@AviVahl
Copy link

AviVahl commented May 14, 2020

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 someContext.users?.filter, which is wrong for many common use cases (e.g. different class instances sharing the same method from prototype).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants