The problem
Most tutorials I found, as well as the RichText documentation (At the time of writing), present you with example attribute definition for RichText that looks like this.
// Attributes definition
cardBackContent: {
type: 'string',
source: 'html',
selector: 'p',
},
Which would be used in an edit and save function like this.
// Edit JSX
<RichText
tagName = "p"
value = {attributes.cardBackContent}
onChange = { (value) => setAttributes({cardBackContent: value}) }
placeholder = "Enter text..."
/>
// Save JSX
<RichText
tagName = "p"
value = {attributes.cardBackContent}
/>
If you happen to be making a block that needs two RichText components in it. You will end up with something like below**—And this is where the code stops working**.
You’ll find that your block seems to work fine while editing and viewing on the front end, but as soon as you open the file again in the editor, it doesn’t validate and appears broken (see console screenshot below).
This is roughly what your code might look like for reference.
// Attributes definition
cardBackContent: {
type: 'string',
source: 'html',
selector: 'p',
},
cardFrontContent: {
type: 'string',
source: 'html',
selector: 'p',
},
// Edit JSX
<div class="card-back">
<RichText
tagName = "p"
value = {attributes.cardBackContent}
onChange = { (value) => setAttributes({cardBackContent: value}) }
placeholder = "Enter text..."
/>
</div>
<div class="card-front">
<RichText
tagName = "p"
value = {attributes.cardFrontContent}
onChange = { (value) => setAttributes({cardFrontContent: value}) }
placeholder = "Enter text..."
/>
</div>
// Save JSX
<div class="card-back">
<RichText
tagName = "p"
value = {attributes.cardBackContent}
/>
</div>
<div class="card-front">
<RichText
tagName = "p"
value = {attributes.cardFrontContent}
/>
</div>
This is an example error seen on opening the file again in the editor.

The error shown above from the console describes that the content produced by the save function (when reloading the page in the editor), doesn’t match what was saved last time the file was edited.
This is a validation check by WordPress to prevent the user interacting with blocks that have broken during an upgrade or something else.