I am trying to use styled-components and other react components on the save() function, but it is not working, the styled-component works just fine on the editor ( edit function ), here is my code for the block:
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
import styled from 'styled-components';
registerBlockType( 'gutenword-blocks/posts', {
title: 'Styled Div',
icon: 'admin-page',
category: 'layout',
edit: function( props ) {
const StyledDiv = styled.div`
height: 300px;
width: 300px;
background: red;
`;
return <StyledDiv></StyledDiv>;
},
save() {
const StyledDiv = styled.div`
height: 300px;
width: 300px;
background: red;
`;
return <StyledDiv></StyledDiv>;
},
} );
Expected behavior The block when added should show red square on the editor screen and on the front-end
Current behavior The red square is showing only on the editor and nothing is showing on the frontend