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

Popover: fix exhaustive-deps warning #45656

Merged
merged 3 commits into from
Nov 10, 2022
Merged

Popover: fix exhaustive-deps warning #45656

merged 3 commits into from
Nov 10, 2022

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Nov 9, 2022

What?

Fix ESLint's react-hooks/exhaustive-deps warnings in the Popover component

Why?

Because #41166

How?

  • Extract some expressions that were too complicated for ESLint to parse to separate variables
  • Add refs.floating to the hook's list of dependencies. Technically refs.floating is a React Ref, but ESLint is not able to determine it and therefore it throws a warning. After discussing with @jsnajdr , we decided that the best option would be to add refs.floating to the list of dependencies, because:
    • it comes from an external dependency (floating ui), and even if we know it's a ref, technically we're not guaranteed
    • since it is supposed to be a ref, adding it to the list of deps won't cause the hook to re-run more often

Testing Instructions

  • Run npx eslint --rule 'react-hooks/exhaustive-deps: warn' packages/components/src/popover/, make sure there are no warnings flagged
  • Smoke test the component in the editor, make sure it works as currently on trunk

@ciampo ciampo added [Type] Code Quality Issues or PRs that relate to code quality [Package] Components /packages/components labels Nov 9, 2022
@ciampo ciampo self-assigned this Nov 9, 2022
@codesandbox
Copy link

codesandbox bot commented Nov 9, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@ciampo ciampo marked this pull request as ready for review November 9, 2022 19:11
Copy link
Contributor

@chad1008 chad1008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 🚢

@ciampo ciampo merged commit 6ab84d5 into trunk Nov 10, 2022
@ciampo ciampo deleted the fix/popover-hooks-deps branch November 10, 2022 20:27
@github-actions github-actions bot added this to the Gutenberg 14.6 milestone Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants