This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
significantly improve render performance on nav hover #709
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.
Currently, hovering a single link in the navigation triggers three renders, one of which rerenders pretty much every component on the page and can take over 250ms on some documentation pages.
Scrolling the navigation on those pages can freeze the browser for seconds.
This PR brings that down to one render of less than 25ms.
The main problem here is that none of the various context values were memoized, which meant that with every rerender of a context provider all the consumers would also rerender. This cascaded from the
useConfigs
indirectly used inPageLayout
through all other contexts.I've gone ahead and memoized all of them - some were rather small performance gains, but it's impossible to say if that might change in the future, so better safe than sorry.