-
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
Extract the Router APIs and context into a dedicated package #50100
Conversation
There's a couple of other "Router APIs" that we already have that are in the site editor (useTitle, useLink), they can probably be moved to this new package ultimately if we feel the need. |
Size Change: -919 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Flaky tests detected in 0050788. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4808809928
|
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.
LGTM 👍
"react-native": "src/index", | ||
"dependencies": { | ||
"@babel/runtime": "^7.16.0", | ||
"@wordpress/element": "file:../element", |
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.
Slightly off-topic: I know we have precedence but I think it makes more sense to mark @wordpress/element
as a peer dependency than a dependency. Starting from a newer version of npm, it should automatically install peer dependency on npm install
.
Also since that we're not directly importing from react
, we don't need to make react
as a peer dependency?
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.
Yeah, to be honest I just copied what we do in other packages. I agree that your proposal seems correct but I'd rather we do it in its own dedicated PR (probably after the npm upgrade too). cc @gziolo
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.
I agree that we need to rethink and document all the practices after we migrate Node and npm to the latest LTS version. For the time being, mirroring other packages is the best approach.
Pre-requisite for #49956
What?
This PR extracts the router provider and some related APIs (useHistory, useLocation) to a dedicated package in order to unblock #49956 allowing us to access the router/history from commands that are independent of the site editor.
How?
This is the exact same code and APIs we already have in the site editor. These APIs were not necessarily meant to be external APIs yet (even if I can see plugins wanting to actually use them). They are very naive, so I'm making all of them as private APIs for now.
Testing Instructions
Nothing really to test, just make sure you can open and navigate the site editor.