JavaScript for WordPress › Forums › Gutenberg Development › Conditional statements before/on save › Reply To: Conditional statements before/on save
April 11, 2018 at 1:41 pm
#44929
alantucker
Participant
Thanks. I have added said code but something strange is going on. After creating my block and adding the content (minus the link) I have noticed that the block is not not showing on the post page, then when I swap back to edit the page it get a “The editor has encountered an unexpected error.”.
Here is my save props code:
save: props => {
const { attributes: { title, message, text, url, colorPaletteControl } } = props;
const isEmpty = text.length > 0 ? false : true;
return (
<div style={ { backgroundColor: colorPaletteControl } } >
<h3 class="subtitle">{ title }</h3>
<div class="message-body">
{ message }
</div>
<p>
{ isEmpty ? (
__( 'No link', 'makeblocks' )
) : (
<a href={ url }>
{ text }
</a>
) }
</p>
</div>
);
},