STEP-9 render Plugins and MSTP Plugin, Component creation
Now we going to create plugins for the Product Page.
Last updated
const mapStateToProps = (args, callback, instance) => {
const [state] = args;
return {
...callback(...args),
socialShare: state.SocialShareReducer.socialShare
};
};
export default {
'Component/ProductActions/Container/mapStateToProps': {
function: mapStateToProps
}
};import { lazy, Suspense } from 'react';
export const SocialShare = lazy(() => import(
/* webpackMode: "lazy", webpackChunkName: "social-share" */
'../component/SocialShare'
));
const renderShortDescription = (args, callback, instance) => (
<>
{ callback.apply(instance, args) }
{ renderSocialShare(instance.props) }
</>
);
const renderSocialShare = (props) => {
const {
socialShare: {
socialShareConfig: {
enabled, productPage, rounded, size
}, providers
},
product: { name }
} = props;
if (!enabled && !productPage) {
return false;
}
return (
<section
block="ProductActions"
elem="Section"
mods={ { type: 'social' } }
>
<Suspense fallback={ null }>
<SocialShare
isRounded={ rounded }
size={ size }
providers={ providers }
quote={ name }
/>
</Suspense>
</section>
);
};
export const config = {
'Component/ProductActions/Component': {
'member-function': {
renderShortDescription
}
}
};
export default config;
render() {
return (
<div block="SocialShare">
{ __('SocialShare') }
</div>
);
}