Created
April 27, 2019 11:34
-
-
Save pbrocks/fe28845468a0736d310639a87a5775ff to your computer and use it in GitHub Desktop.
From the Handbook, creating a higher order component is a best practice for the WordPress abstraction layer of React.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createHigherOrderComponent } = wp.compose; | |
const withClientIdClassName = createHigherOrderComponent( ( BlockListBlock ) => { | |
return ( props ) => { | |
return <BlockListBlock { ...props } className={ "block-" + props.clientId } />; | |
}; | |
}, 'withClientIdClassName' ); | |
wp.hooks.addFilter( 'editor.BlockListBlock', 'my-plugin/with-client-id-class-name', withClientIdClassName ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment