How to use the @wordpress/components.withState function in @wordpress/components

To help you get started, we’ve selected a few @wordpress/components 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 / editor / hooks / copy-content / index.js View on Github external
className="components-menu-items__button"
			onCopy={ () => setState( { hasCopied: true } ) }
			onFinishCopy={ () => setState( { hasCopied: false } ) }
		>
			{ hasCopied ?
				__( 'Copied!' ) :
				__( 'Copy All Content' ) }
		
	);
}

const Enhanced = compose(
	query( ( select ) => ( {
		editedPostContent: select( 'core/editor', 'getEditedPostContent' ),
	} ) ),
	withState( { hasCopied: false } )
)( CopyContentButton );

const buttonElement = ;

addFilter(
	'editor.EditorActions.tools',
	'core/copy-content/button',
	( children ) => [ ...children, buttonElement ]
);