-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
I'm using datocms-structured-text-to-html-string and I have inserted a custom block (HTML block with a table inside) but for some reason it is rendering twice and the second one has incorrect tags when it should it only render once. Can anyone help or point out if I'm doing something wrong?
Here is the code snippet:
const options = {
renderBlock({ record, adapter: { renderNode } }: any) {
return renderNode(record.table);
},
};
const raw = useMemo(
() => render(content[translation], options) as string,
[content, translation]
);
return (
<div
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(raw) }}
/>
)
record.table contains when I log it to the console:
<table border="1" style="border-collapse: collapse;">
<tbody>
<tr>
<td>Hello 1</td>
<td>Hello 2</td>
<td>Hello 3</td>
</tr>
<tr>
<td>Hello 1</td>
<td>Hello 2</td>
<td>Hello 3</td>
</tr>
<tr>
<td>Hello 1</td>
<td>Hello 2</td>
<td>Hello 3</td>
</tr>
<tr>
<td>Hello 1</td>
<td>Hello 2</td>
<td>Hello 3</td>
</tr>
<tr>
<td>Hello 1</td>
<td>Hello 2</td>
<td>Hello 3</td>
</tr>
<tr>
<td>Hello 1</td>
<td>Hello 2</td>
<td>Hello 3</td>
</tr>
<tr>
<td>Hello 1</td>
<td>Hello 2</td>
<td>Hello 3</td>
</tr>
<tr>
<td>Hello 1</td>
<td>Hello 2</td>
<td>Hello 3</td>
</tr>
<tr>
<td>Hello 1</td>
<td>Hello 2</td>
<td>Hello 3</td>
</tr>
<tr>
<td>Hello 1</td>
<td>Hello 2</td>
<td>Hello 3</td>
</tr>
</tbody>
</table>
and it's showing up like this:
Metadata
Metadata
Assignees
Labels
No labels
