-
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
Fix sample code on InputControl docs #59517
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Thanks for the PR! Looking at #54908, it seems that it is currently recommended to use |
Thank you for bringing this up @t-hamano! I have seen the packages imported this way and never thought about the distinction until just now. More info on the changes in React abstractionPossible reason to use
|
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.
Checked InputControl component with
import {useState} from 'react'
This abstraction works. There may be additional features of useState that are advanced and customized for the useState
hook for WordPress. If this is the case, the block will break and the user will have to import the package directly from WordPress to use this functionality. This is a known limitation per
Note that we do have some functions in @wordpress/element that are additional like renderToString or createInterpolateElement...
There's strictly no difference between It seems that right now:
So let's just maintain that status-quo for now. which I guess mean ship this PR. |
@@ -126,7 +126,7 @@ export function UnforwardedInputControl( | |||
* | |||
* ```jsx | |||
* import { __experimentalInputControl as InputControl } from '@wordpress/components'; | |||
* import { useState } from '@wordpress/compose'; | |||
* import { useState } from '@wordpress/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.
This should be "react" I think.
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.
Changed import declaration to react
.
This is sample code in the documentation, the code is wrapped in Markdown syntax representing JSX
```jsx
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 has already been mentioned, but isn't it "react" instead of "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.
I will look into it. It's possible when I was making changes it wasn't syncing to the correct branch.
Still getting familiar with the workflow of Git and contributing upstream vs. local working copy.
Will report back, @t-hamano
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.
This should be resolved now.
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 seems that right now:
For documentation purpose, we use react
For code, we're still using @wordpress/element
Riad put it really well. On top of that, other than another minor CHANGELOG correction, think this should be good to go - thanks!
Thank you @youknowriad, @t-hamano and @tyxla for support! I will update and squash the commits to clean this up. This has been a great exercise in understanding commit history and the upstream flow, so I really do appreciate your feedback and direction! |
c47650b
to
54dab36
Compare
Thank you for the support on this @t-hamano.
Thanks again! This was by far the most challenging software thing I've ever wrestled with 😄 Requesting final review @tyxla - thanks for the help on the CHANGELOG update. |
@tyxla - I tried to change the commit message and somehow added quite a few more commits. Please hold off on reviewing. I'll get some help from my mentor after they return from WC Asia. |
/assign |
Don't worry too much about commit messages, the person merging the PR will change and adapt it properly. |
1106940
to
d03908b
Compare
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! I only deleted unnecessary spaces in CHANGELOG.
Thank you everyone for helping out on this! |
* Docs: Fixed sample code on InputControl docs * Docs: Fixed sample code for InputControl * Docs: Fixed sample code for InputControl * Import useState from react package * Use wordpress/element package on source code, React for documentation purposes. * Using react in sample code (documentation) * Remove unnecessary space --------- Co-authored-by: flexseth <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: tyxla <[email protected]>
What?
InputControl code samples broken - the
useState
package has moved fromwordpress/compose
towordpress/element
How?
When trying to use an InputControl, I found that many of the Gutenberg package imports had been updated, but not those for the InputControl component. This affects the Developer Documentation and also Storybook.
There were three declarations that needed to be changed in the Gutenberg folder. Search & Replace in VS Code worked to fix the code and this PR represents the updated Gutenberg codebase with changes to the developer documentation.
Testing Instructions
npx @wordpress/create-block input-control-block
Testing the broken interface
change
to
About this PR
This PR simply changes the location of the package imports, so no one else runs into this when trying to work with the InputControl component.
Screenshots included