[ad_1]
I have created a custom block that lets the user build a query and pick a pattern for display purposes. I am able to render the pattern in the frontend using php but not in the editor. Is there a way to use a pattern in edit.js in a dynamic custom block?
edit.js:
{posts &&
posts.map((post) => {
[USE PATTERN HERE ??]
);
})}
I am able to accomplish this in render.php
while ($query->have_posts()) : $query->the_post();
$posts .= do_blocks( ‘<!– wp:pattern {“slug”:”‘ . $pattern . ‘”} /–>’ );
endwhile;
Thanks
[ad_2]
In the edit.js you need to use JavaScript – a variant of React.js to be more exact. The extension of the file (.js) implies that you can only use the JavaScript.