-
Notifications
You must be signed in to change notification settings - Fork 28
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
add initial guide for using @wordpress packages on the frontend #15
add initial guide for using @wordpress packages on the frontend #15
Conversation
I chatted about this initial draft with @nicholasio and his main points are:
He also uncovered that at least currently the I will also revise the first draft to be much more conservative. |
I have created an issue on the Gutenberg repo for the API Fetch package relying on lodash: WordPress/gutenberg#39495 |
@nicholasio I have reworded the guide to what we had talked about. Would love to get your 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.
Overall this is looking good and aligned with what we discussed.
Left two minor comments,
|
||
### [`@wordpress/html-entities`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-html-entities/) | ||
|
||
The [`@wordpress/html-entities`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-html-entities/) package is super useful when working with data from the WordPress REST API when you manually need to decode html entities because you may not want to use the `rendered` value due to having to use `innerHTML` or `dangerouslySetInnerHTML` if you are using react. |
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 package seems to be "safe" to use on the front-end.
However, I'm not sure about the suggested use case, since the raw
value that comes from the API does not include the rendered blocks AND doesn't go through WP filters it feels like this might not be a real use case. Thoughts?
|
||
There are some packages that suit themselves very well for being used outside of the editor. This list is not comprehensive and if something is not listed here it doesn't mean that it cannot be used on the frontend. These are just some good examples of packages that showed they work well on the frontend. | ||
|
||
### [`@wordpress/dom-ready`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-dom-ready/) |
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.
Thoughts on including a dependency for such simple utility functions versus adding it in the scaffold?
Additionally, do you know the benefits of the additional checks? I'm guessing it's accounting for a situation where the DOM is already loaded by the time your script runs so you don't need to add the callback.
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.
@nicholasio Yeah that exactly was my understanding of the checks.
And from my perspective, the reason why I like to use the package is just 100% consistency. I've gotten used to it in the editor and instead of having to manually use different approaches just using this simple helper just reduces the mental overload.
This is the first draft of the best practice guide for working with
@wordpress/packages
on the frontend.I have some questions for @nicholasio on how we can actually achieve what I am talking about here within
10up-toolkit