Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function PostContentEdit() {
const [ content, setContent ] = useEntityProp( 'postType', 'post', 'content' );
const initialBlocks = useMemo( () => {
const parsedContent = parse( content );
return parsedContent.length ? parsedContent : undefined;
}, [] );
const [ blocks = initialBlocks, setBlocks ] = useEntityProp(
'postType',
'post',
'blocks'
);
const [ isDirty, isSaving, save ] = useEntitySaving(
'postType',
'post',
'content'
);
return (
<>
<button disabled="{"> {
setContent( content( { blocks } ) );
save();
}, [ content, blocks ] ) }
></button>