-
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 ContextSystemProvider
and the useUpdateEffect
util to ignore exhaustive-deps
#45044
Conversation
Tooltip
component to temproarily ignore the exhaustive-deps
eslint rule ## Why? There are several warnings in this component. One, in index.js
will likely need a more comprehensive refactor to avoid unexpected changes in behavior. The rest are missing dependencies in native files. Because the Components squad generally lacks the React Native expertise and tools/environments to effectively refactor these components, we'll [defer to the native team to handle when they're ready](https://github.com/WordPress/gutenberg/issues/44226). ## How? Added inline ignore comments to all exhaustive-deps
warnings in the Tooltip
component directoryContext
to ignore exhaustive-deps
Size Change: -16 B (0%) Total Size: 1.28 MB
ℹ️ View Unchanged
|
Context
to ignore exhaustive-deps
ContextSystemProvider
and the useUpdateEffect
util to ignore exhaustive-deps
I rather suspect this was a mistake done in haste, rather than intentional. Alternatively, it may have been some workaround for the somewhat limited scope of the Gutenberg TypeScript configuration in early 2021. If the hooks are the same and there is no issue with TypeScript then I see no reason not to consolidate them and delete some code 😈 |
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.
Yeah, seems like the disable is inevitable.
- Once we activate the rule for the Components package, would it make sense to configure it to validate the dependencies of this custom hook?
I think so!
42ccabf
to
8af7a03
Compare
Thanks @sarayourfriend and @mirka! I've gone ahead and removed the local I'll update #41166 shortly to include @mirka, your approval was before the update to the |
Yep, still good! 🚢 |
What?
Updates the two
useUpdateEffect
utility hooks withinContextSystemProvider
andutils/hooks
to ignore theexhaustive-deps
eslint ruleWhy?
The hook passes a non-array literal dependency list out of necessity (it's accepting the dependencies from the consumer and doesn't know what they are in advance). Further, the
effect
value, which is also passed in from the consumer is an additional missing dependency.Adding
effect
to the deps array would require either a spread operator (which would trigger a differentexhaustive-deps
warning) or some more involved logic to handle the addition... but none of this would solve the original warning described above.Thoughts/questions for the future:
ContextSystemProvider
to import theuseUpdateEffect
hook from utils? cc @sarayourfriend in case you have any insight 🙂How?
Added inline ignore comments to all
exhaustive-deps
warning in both hooks