-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Interactivity API: Add support for lazy-loaded derived state props #9673
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
Interactivity API: Add support for lazy-loaded derived state props #9673
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
luisherranz
left a comment
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 David! 🎉
My only thought is if maybe we should rename derivedStatePropsAccessed to derivedStateClosures so it's more explicit that it is related to closures only? What do you think?
Naming is hard. 😅 We can agree that using the term "derived state" is fine, as we use it extensively in the documentation. Regarding "props accessed" vs. "closures", maybe the "closure" part is implicit already in "derived state"? Only those properties are defined using closures. And I added the term "accessed" to indicate that these derived state props were accessed during server-side processing. I know the term is a bit long, and I don't mind changing it to EDIT: What about |
|
My thinking is that not all derived state needs to be tracked, only the derived state that is defined as closures in the server. There's derived state that is still "accessed" but it's value in the server is static. |
Makes sense. I just changed the name to |
|
Can you change the |
This PR handles the server-side part to add support for "lazy" derived state props. From the trac ticket description:
The way it works is by informing the iAPI runtime which Closures have been evaluated on the server, and serializing their paths into a data structure that is serialized along with the initial state and configuration.
There's also a special case with the
data-wp-each-childdirective. I should know if the corresponding parentdata-wp-eachdirective is using a derived state prop to render the list. For nesteddata-wp-eachdirectives, the value assigned indata-wp-each-childelements is the one of the top-mostdata-wp-eachdirective.Trac ticket: https://core.trac.wordpress.org/ticket/63898
Related Gutenberg issue: WordPress/gutenberg#70872
Related Gutenberg PR: WordPress/gutenberg#71125
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.