PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.8.2
GenerateBlocks v1.8.2
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / extend / dynamic-content / hoc / withDynamicContent.js
generateblocks / src / extend / dynamic-content / hoc Last commit date
withDynamicContent.js 4 years ago
withDynamicContent.js
28 lines
1 import { Fragment } from '@wordpress/element';
2 import InspectorControls from '../InspectorControls';
3 import DynamicRenderer from '../DynamicRenderer';
4
5 export default ( WrappedComponent ) => {
6 return ( props ) => {
7 const { attributes, setAttributes, context, name } = props;
8
9 const newProps = attributes.useDynamicData &&
10 ( !! attributes.dynamicContentType || !! attributes.dynamicLinkType )
11 ? Object.assign( {}, props, {
12 ContentRenderer: DynamicRenderer,
13 } ) : props;
14
15 return (
16 <Fragment>
17 <WrappedComponent { ...newProps } />
18 <InspectorControls
19 context={ context }
20 attributes={ attributes }
21 setAttributes={ setAttributes }
22 name={ name }
23 />
24 </Fragment>
25 );
26 };
27 };
28