[wp-trac] [WordPress Trac] #63898: Add support for lazy-loaded derived state props
WordPress Trac
noreply at wordpress.org
Fri Aug 29 17:59:42 UTC 2025
#63898: Add support for lazy-loaded derived state props
-------------------------------+-----------------------------
Reporter: darerodz | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Interactivity API | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
There is a problem with [https://developer.wordpress.org/block-editor
/reference-guides/interactivity-api/api-reference/#derived-state derived
state props] when the store containing them is not loaded before
hydration, which can happen with stores loaded asynchronously, e.g.,
{{{@wordpress/interactivity-router}}}, and also they have a PHP equivalent
used for server-side rendering.
In that case, when those missing derived state props are evaluated, they
will return {{{undefined}}}, and the directives subscribed to that value
will replace the value generated on the server with the PHP function with
{{{undefined}}}, effectively removing the HTML generated on the server.
The Interactivity API should be aware of which values were generated on
the server via a PHP Closure (derived state props) and avoid replacing the
directive's value on the client until a getter is available that can
correctly recalculate it.
This requires serializing which state props are closures that were used
during directive processing to generate the HTML markup.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63898>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list