I am trying to implement Panel Color in the Inspector Control for a custom block but can’t seem to figure it out. Below is the JSX code that attempts it. It renders the block, but when it’s in focus, it encounters a Minified React error #130.
const { registerBlockType, InspectorControls, PanelColor } = wp.blocks;
registerBlockType( 'test/test', {
title: 'Test',
icon: 'universal-access-alt',
category: 'layout',
edit( { attributes, className, setAttributes } ) {
const { backgroundColor } = attributes;
const onChangeBackgroundColor = newBackgroundColor => {
setAttributes( { backgroundColor: newBackgroundColor } );
};
return (
<div className={ className }>
{ !! focus && (
<InspectorControls>
<PanelColor
title={ 'Background Color' }
value={ backgroundColor }
onChange={ onChangeBackgroundColor }
/>
</InspectorControls>
) }
</div>
);
},
save( { attributes, className } ) {
const { backgroundColor } = attributes;
return (
<div className={ className }>
</div>
);
},
} );