-
Notifications
You must be signed in to change notification settings - Fork 858
[fix] Keep Flyout Manager sync'd across React roots. #9075
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
base: feat/flyout-system
Are you sure you want to change the base?
[fix] Keep Flyout Manager sync'd across React roots. #9075
Conversation
💔 Build Failed
Failed CI StepsHistory
|
💚 Build Succeeded
|
"unified": "^9.2.2", | ||
"unist-util-visit": "^2.0.3", | ||
"url-parse": "^1.5.10", | ||
"use-sync-external-store": "^1.6.0", |
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.
Note to other reviewers: useSyncExternalStore
is shipped with React starting from version 18.0. We need this shim for React 17 support
*/ | ||
|
||
import React, { createContext, useContext } from 'react'; | ||
import { useFlyoutManagerReducer } from './hooks'; |
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.
useFlyoutManagerReducer
is now only used in tests. Do we need to keep it for any reason?
state, | ||
...rest, | ||
goToFlyout, | ||
getHistoryItems: () => { |
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.
Since this is selector logic, maybe a better architecture would be to move getHistoryItems
to the store. Doing so would make it so that we don't need to destructure goToFlyout
from the store on line 28.
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.
Thank you so much for working this out! Left a couple of comments
Thanks @tsullivan I'll make the adjustments and open for review. |
As titled. Adds a module-level singleton instance of the store and enhances the provider with
useSyncExternalStore
, (adds a Meta-maintained shim to support React 17).I wrote this pretty quickly, and leveraged Gemini in some cases. Should be reviewed and revised with this in mind.