-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
issue: bugIssue reporting a bugIssue reporting a bug
Description
What version of @strapi/blocks-react-renderer are you using?
npm, node, react, strapi-* - the latest versions
What's Wrong?
The code below is likely working, but Strapi returns the data in a different format. The API returns the Code block inside a Paragraph, and the function code is never called.
| it('parses code blocks to plain text', () => { |
<BlocksRenderer
content={[
{
type: 'code',
children: [
{
type: 'text',
text: 'const a = 1;',
},
{
type: 'link',
url: 'https://test.com',
children: [{ type: 'text', text: 'const b = 2;', bold: true }],
},
],
},
]}
</>Below, I have attached a screenshot of the server's response:
Here is my workaround:
<BlocksRenderer content={children}
blocks={{
paragraph: ({children}) => {
return (
<p>
{
React.Children.map(children, (item) => {
const {props: {code, text}} = item;
if (code) {
return <span className={styles.highlight}>{text}</span>;
}
return item;
})
}
</p>
)
},To Reproduce
Open DevTools...
Expected Behaviour
The code function should be called.
joeygrable94
Metadata
Metadata
Assignees
Labels
issue: bugIssue reporting a bugIssue reporting a bug