Reputation: 1884
My problem specifically is that I would like to be able to create dynamic templates, depending on the type of item contained in a certain record. I would like to store these components as strings in the database and render them dynamically as the items are loaded. The templates would need to be able to handle dynamic react variables. They are not just html strings as in some of the other examples on stackoverflow.
How might one go about doing this? Is it even possible?
Upvotes: 3
Views: 830
Reputation: 4661
You can use dangerouslySetInnerHTML
, documented here.
function createMarkup() { return {__html: 'First · Second'}; };
<div dangerouslySetInnerHTML={createMarkup()} />
This is also discussed here.
Upvotes: 1