-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Update SlotFillProvider to the new context API #11123
Conversation
I'm thinking we should upgrade to React v16.6 first so that we can use |
I'd rather have this upgrade in 5.0. Using legacy APIs inside Gutenberg justifies its use within third-party (plugins, etc), which are a lot harder to migrate. Also, when we upgrade React we might end doing things differently (hooks anyone? where |
Moving out of 4.2 as it doesn't really touch the public API but still good to have for 5.0 among other react deprecations/upgrade. |
Wanted to note that this PR is blocked until the tests are fixed. The reason why they fail is that we are using an old version of enzyme that doesn't support the new React Context API. Updating |
Update: I'm going to explore update those tests to the react-test-renderer. Also, I've created #11214 to keep track of workarounds we do to make (the versions we use of) enzyme and enzyme-adapter-react-16 work with React. |
875b034
to
4c4a70e
Compare
<div> | ||
1 | ||
</div>, | ||
<button |
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 that, previously, we weren't doing snapshot testing and the button
component wasn't checked for.
<div> | ||
2 | ||
</div>, | ||
<button |
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 that, previously, we weren't doing snapshot testing and the button
component wasn't checked for.
first | ||
second | ||
</div>, | ||
<button |
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 that, previously, we weren't doing snapshot testing and the button
component wasn't checked for.
Tests updated - note that tests are migrated in atomic commits one by one so it's easier to compare the changes. This is ready for a second review. |
mmm, some other tests still need to be migrated:
|
Tests have been fixed. This is ready for review. |
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.
It would be nice to move all test updates to their own PR. Ensure it works with master
and then upgrade Slot and Fill to the new Context API. Otherwise, it's not that obvious if we didn't break anything.
I also would love to avoid using snapshots for Slot
tests as they become very hard to reason after changes introduced. In general they are awesome for UI components, but Slot
is more container which doesn't care as much about UI but to ensure that all fills are properly rendered.
ccdf0bb
to
d04fb12
Compare
Nice work, changes in this PR looks great. There are a few e2e tests which ensure that plugins can extend editor, so I think it also covers Slot and FIll logic indirectly. |
Cool! The base branch is #11314 I'll wait until that's approved and merged, then I'll rebase this with master and will merge. |
6ac3037
to
4e5b61c
Compare
cb19a4e
to
cc36d71
Compare
cc36d71
to
08daa84
Compare
08daa84
to
24a9729
Compare
To be merged after #11314 lands.
The SlotFillProvider is using the React's legacy context API which will be removed in the next major version and was added as a deprecation in StrictMode in 16.6.0.
This PR updates the SlotFillProvider to the stable React's context API.
Test
/
inserter to add blocks.