I'm working in a plugin for blocks with the npx @wordpress/create-block
structure. In the edit() function I've imported Vime library to add a video. This library supports React.
So, after add the library to the plugin node_modules
, my edit file is:
import { Player, Youtube } from "@vime/react";
export default function Edit({ className, attributes, setAttributes }) {
return (
<div {...useBlockProps()}>
<Player controls>
<Youtube videoId="DyTCOwB0DVw" />
</Player>
</div>
);
}
It works. I can insert the block in the editor and the video player is rendered:
After that, I try to do the same in the save file:
import { useBlockProps } from "@wordpress/block-editor";
import { Player, Youtube } from "@vime/react";
export default function save({ attributes }) {
return (
<div {...useBlockProps.save()}>
<Player controls>
<Youtube videoId="DyTCOwB0DVw" />
</Player>
</div>
);
}
But this doesn't work. The block is not rendered in the front end and, when I add a block in the editor, the editor show me a blank page. Am I calling the library incorrectly or could it be a bug in the library or maybe some incompatibility with my theme? I appreciate any hint or help.