Avoid spurious model lookup context changes #3518
Merged
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.
Thanks to Colin for finding this problem.
useContext will force a re-render whenever it value changes -- we were changing the object reference of our ModelLookup object every time we rendered it, leading to a cascade of spurious re-renders throughout the hierarchy below.
Think the not-so recent (oct. 2022) changes to TabContainer to include a RefereshContext exacerbated this problem such that components on hidden tabs were also re-rendering on tab switch.
To see the effect of this change, simply put a console log statement in any render method within a tab and start switching tabs in the tab container.
Hoist P/R Checklist
Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.
develop
branch as of last change.breaking-change
label + CHANGELOG if so.If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.