I have a modal
component that receives two strings from a home
component, it's easy to take those strings and render them on one single string with the correct markup on the modal.tsx
with this
return <>No markup: {firstString}, with markup: <strong>{secondString}<strong><>
But what I actually want to do is render the whole string first in the other component to keep the modal
component agnostic and just render whatever string and its markup.
The problem is that on the home
component if I store the string with markup on state, I then have to use dangerouslySetInnerHTML
on the modal.
Home.tsx
const message = `No markup: {firstString}, with markup: <strong>{secondString}<strong>`
Modal.tsx
<div dangerouslySetInnerHTML={{ __html: message }}>{}</div>
Is there another way to do this, and if not is this actually dangerous?