-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 withNotices
to pass exhaustive-deps
#45530
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: 0 B Total Size: 1.28 MB ℹ️ View Unchanged
|
I don't think it was intentional and like you noted the deps are memoized so it shouldn't affect the tests. As a side note, this reminds me that there maybe should be a test that |
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.
🚀
What?
Updates the
withNotices
higher order component to pass theexhaustive-deps
eslint rule.Why?
Part of the effort in #41166 to apply
exhuastive-deps
to the Components packageHow?
Adding the two missing dependencies to the dependency array of the
BaseComponent
in the affected test.Previously, this was an empty dep array, so the effect would only fire on the first render. Adding them appears safe because both
noticeOperations
andnotifications
are properly memoized when originally declared, so the effect should only fire when one of them is actually updated in some way.cc @stokesman: It was a while ago, but do you remember your thought process when writing this test - was it intentionally to limit the effect the initial render? Curious if you think this change will negatively effect the reliability of the test.
Testing Instructions
npx eslint --rule 'react-hooks/exhaustive-deps: warn' packages/components/src/higher-order
navigation
unit tests still pass