Best approach for dynamic block rendering in the editor #28684
Comments
We tend to recommend client-blocks because it's intrinsic to how the editor is meant to work: direct manipulation with instant feedback for all manipulations, which we can only ensure properly client side. |
What if one day we would have React Server Components implemented in PHP? I guess it's far in the future to see it enabled in React, but they are working on the serialization layer so, in theory, it could work with any language. As far as I understood the idea, it would address most of the concerns with the code duplication between |
The streaming protocol would indeed be cool to explore given we already have the block abstraction established. It wouldn't be too out there to consider passing component state through it. We briefly discussed this with @luisherranz in the context of Frontity and how it could consume blocks in the front-end in the future. But that also points to another important distinction of server-client, which is |
This is a good reminder. It's easy to fall into a trap of wanting to share code between |
tellthemachines commentedFeb 3, 2021
•
edited
What problem does this address?
Currently, core dynamic blocks use one of two different approaches to rendering in the editor:
ServerSideRender
, which reproduces the markup defined in the block'sindex.php
(e.g. Archives, Latest Comments)index.php
in JS. (e.g. Categories, Latest Posts)The developer docs recommend client-side rendering:
However, it's not clear that client-side rendering does in fact work better:
ServerSideRender
load faster than blocks using JS to render the same amount of content.What is your proposed solution?
I'd love to see us leverage
ServerSideRender
on all our dynamic blocks, but in order to do so we'll need to improve it:Thoughts and ideas welcome!
(This issue was prompted by work on #28265 , where I opted to use to use
ServerSideRender
but ran into the issue of not being able to use block context to customise markup output.)The text was updated successfully, but these errors were encountered: