How to use the @wordpress/core-data.useEntitySaving function in @wordpress/core-data

To help you get started, we’ve selected a few @wordpress/core-data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / packages / block-library / src / post-content / edit.js View on Github external
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 ] ) }
			&gt;</button>

@wordpress/core-data

Access to and manipulation of core WordPress entities.

GPL-2.0-or-later
Latest version published 9 days ago

Package Health Score

95 / 100
Full package analysis