In React.js, how would I render the component from the inline view of the component?

My problem is that I would like to be able to create dynamic templates depending on the type of element contained in a particular record. I would like to store these components as strings in a database and display them dynamically when items are loaded. The templates would have to handle dynamic react variables. These are not just html strings as in some of the other examples on stackoverflow.

How can you do this? Is it possible?

+3


source to share


1 answer


You can use dangerouslySetInnerHTML

registered here .

function createMarkup() { return {__html: 'First · Second'}; };
<div dangerouslySetInnerHTML={createMarkup()} />

      



It is also discussed here.

+1


source







All Articles