Skip to content
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

Pitfalls working with @wordpress/data, useSelect and useDispatch and how to avoid those. #190

Closed
bph opened this issue Dec 19, 2023 Discussed in #184 · 11 comments
Closed

Comments

@bph
Copy link
Collaborator

bph commented Dec 19, 2023

Discussed in #184

Originally posted by bph December 14, 2023
This post would be an updated rewrite of Jarda Snajdr post on his personal blog two years ago.0
adding a few more practices and patterns that address problems that Jarda witnessed causing performance issues recently.

The useSelect hook implementation itself has also evolved significantly in the last year or so, having been rewritten to use React 18’s useSyncExternalStore, and adding optimizations like granular subscriptions to individual stores or conditional “lazy” subscriptions.

It would be for a reader who is already familiar with @wordpress/data and useSelect and useDispatch, uses them successfully to write a custom block or plugin, but wants to improve their game and to learn more details.

Note: Discussion title is a work in progress... it will be fixed in review process.

@jsnajdr
Copy link
Member

jsnajdr commented Jan 4, 2024

Looking forward to start working on the article! 🚀

@bph
Copy link
Collaborator Author

bph commented Jan 4, 2024

wonderful. Just assigned the topic to you, Jarda!

@jsnajdr
Copy link
Member

jsnajdr commented Mar 14, 2024

Here's a draft of the article available for comments: https://docs.google.com/document/d/1gTuFwR0O2P4s8KZQ0VNy9tkVwhT1YBptL2WlLr0S-bM/edit

@ryanwelcher
Copy link

This is a great article @jsnajdr! I've left some comments/thoughts and am happy to discuss!

@jsnajdr
Copy link
Member

jsnajdr commented Mar 15, 2024

This is now a draft post in WordPress: https://developer.wordpress.org/news/?p=3015&preview=1&_ppp=bad243e253

@bph
Copy link
Collaborator Author

bph commented Mar 15, 2024

Hi @jsnajdr here is the

Pre-publishing checklist: (updated 1/29/2024)

  • Post Title and subheaders in sentence case
  • Are Category or Categories selected?
  • Are Tags identifies?
  • Is there an explicit Excerpt?
  • Are all images files uploaded to the media library
  • Do all images have an alt-text?
  • Assign or upload a featured image
  • Props added? (See Guidelines)
  • add copy for a social post as comment to this issue (example)
    🙌 Publish! 📗

Post-publishing checklist

  • add Props for reviews to #props channel in WP Slack (Example) (use Slack handles)
  • close the issue with a comment to link to the published post
  • close the accompanying discussion with the link to the published post.

@jsnajdr
Copy link
Member

jsnajdr commented Mar 18, 2024

Social copy:

Learn how to use the useSelect React hook more effectively. This article offers many tips and tricks and insights about this part of the @wordpress/data package.

@justintadlock
Copy link

I know this has already been reviewed, and we're close to publishing. But I just did a quick run-through the article, and something stood out to me as missing.

When or why should I (as the reader) use the useSelect() hook? It might not hurt to throw this into the introduction section. That way, it just gives the reader more of a sense of whether this is something they want to dive into.

@jsnajdr
Copy link
Member

jsnajdr commented Mar 22, 2024

When or why should I (as the reader) use the useSelect() hook?

I added a sentence to the opening paragraph that describes where and why the hook is used -- in the UI components of the block editor and of custom blocks. That should make the article start less abruptly, and should give you some picture whether this is an area of WordPress development that you are interested in.

@bph
Copy link
Collaborator Author

bph commented Apr 2, 2024

@bph bph closed this as completed Apr 2, 2024
@bph
Copy link
Collaborator Author

bph commented Apr 12, 2024

scheduled for April 22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Published (Done)
Development

No branches or pull requests

4 participants