Skip to content
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

[core] fix(HotkeysProvider): avoid unnecessary children re-renders #6643

Closed
wants to merge 1 commit into from

Conversation

adidahiya
Copy link
Contributor

Fixes #5178

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

WIP - attempts to apply https://gist.github.com/stephen/873773683fc15d1fb290b338a6c59d38

Reviewers should focus on:

No regressions in hotkey APIs
No regressions in advanced usage APIs with nested providers: #4767

Screenshot

N/A

// if we are working with an existing context, we don't need to generate our own dialog
return (
<HotkeysContext.Provider value={[state, dispatch]}>
<HotkeysContext.Provider value={[reducedState, dispatch]}>
Copy link
Contributor

@braeden braeden Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(totally aware this is a draft) But I think we actually want to memo this reference itself too. eg.

const memoValue = React.useMemo(() => [reducedState, dispatch], [])

Also have seen this show up in some perf-profiles, but haven't had the time to follow-up. Without a memo, each time this provider renders, it also re-renders every single consuming child (even if state/dispatch) haven't changed.

Edit: #6652

@adidahiya
Copy link
Contributor Author

closing in favor of #6652

@adidahiya adidahiya closed this Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple re-rendering by useHotkey
2 participants