import { useDispatch, useSelect } from '@wordpress/data'; import React from 'react'; export const withMeta = ( Component: React.ComponentType, ) => { const Comp = (props: Props) => { const meta = useSelect((select) => { return ( (select('core/editor') as any)?.getEditedPostAttribute('meta') ?? {} ); }, []); const { editPost } = useDispatch('core/editor'); const updateMeta = (key: string, value: any) => { editPost({ meta: { ...meta, [key]: value } }); }; return ; }; Comp.displayName = `withMeta(${Component.displayName || Component.name || 'Component'})`; return Comp; };