-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Components: refactor BorderControl
to pass exhaustive-deps
#41259
Conversation
BorderControl
to pass exhaustive-deps
@@ -56,7 +56,7 @@ export function useBorderControl( | |||
|
|||
onChange( newBorder ); | |||
}, | |||
[ onChange, shouldSanitizeBorder, sanitizeBorder ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaronrobertshaw , do you remember if there's any particular reason why you added sanitizeBorder
to the list of dependencies here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Honestly can't recall and looks like I added it before tidying up local experimentation and drafting the initial PR.
I probably just had it in my head that changing sanitizeBorder
would mean a changed callback. It makes sense that coming from an outer scope it isn't a valid dependency and should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this @chad1008 👍
✅ No linting errors
✅ BorderControl
and BorderBoxControl
continue to function in Storybook
✅ Border controls within the editor work correctly
LGTM! 🚢
@@ -56,7 +56,7 @@ export function useBorderControl( | |||
|
|||
onChange( newBorder ); | |||
}, | |||
[ onChange, shouldSanitizeBorder, sanitizeBorder ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Honestly can't recall and looks like I added it before tidying up local experimentation and drafting the initial PR.
I probably just had it in my head that changing sanitizeBorder
would mean a changed callback. It makes sense that coming from an outer scope it isn't a valid dependency and should be removed.
Just chiming in to say it looks like the testing instructions for these PRs could be simplified with command line overrides. I tested: |
What?
Updates the
BorderControl
component to satisfy theexhaustive-deps
eslint ruleWhy?
Part of the effort in #41166 to apply
exhuastive-deps
to the Components packageHow?
sanitizeBorder
from dependency array.sanitizeBorder
isn't a prop, and mutating it doesn't rerender the component so it's not a valid dependencycolorSelection
andstyleSelection
to dependency arrayTesting Instructions
exhaustive-deps
eslint rule #41166, OR manually set'react-hooks/exhaustive-deps': 'warn'
in your local eslint filenpx eslint packages/components/src/border-control