-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Navigator
: Split NaviagtorContainer
from NavigatorProvider
#46099
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
@ciampo: What do you think of this refactor? Needed so that I can have navigator links for the Styles panel that live outside of the Styles panel in #45960. (You click on the block in the Style Book and it navigates to the block's screen in Styles.) Two alternative approaches I can think of:
Alternative 1 above is kinda tempting. But would splitting |
Size Change: +115 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
let { children } = contextProps; | ||
|
||
const hasScreenChildren = Children.toArray( children ).some( | ||
( child ) => isValidElement( child ) && child.type === NavigatorScreen |
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.
Hm, actually, this doesn't really work in practice because children are often a component that wraps NavigatorScreen
e.g. GlobalStylesNavigatorScreen
.
I'm going to go with this approach. That way all of the work can stay in |
I never actually wondered if |
What?
Splits a new
NavigatorContainer
component from the existingNavigatorProvider
component. This means thatNavigatorProvider
will provide a context and not render anything.Why?
This allows me to hoist
NavigatorContext
up to the root of the site editor and placeNavigatorLink
s in places outside of the Styles panel'sNavigatorProvider
. See #45960.How?
Moves the non-context logic out of
NavigatorProvider
and intoNavigatorContainer
. Backwards compatibility is maintained by havingNavigatorProvider
wrap its children withNaviagtorContainer
if it detects aNavigatorScreen
child.Testing Instructions
Screenshots or screencast