Components: refactor withNotices to pass exhaustive-deps #45530
Merged
Components: refactor withNotices to pass exhaustive-deps #45530
withNotices to pass exhaustive-deps #45530Conversation
|
|
44 tasks
|
Size Change: 0 B Total Size: 1.28 MB ℹ️ View Unchanged
|
Contributor
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Updates the
withNoticeshigher order component to pass theexhaustive-depseslint rule.Why?
Part of the effort in #41166 to apply
exhuastive-depsto the Components packageHow?
Adding the two missing dependencies to the dependency array of the
BaseComponentin 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
noticeOperationsandnotificationsare 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-ordernavigationunit tests still pass