Hey" return (
Some bold text: {a}
) } ...">

How to render jsx / html inside a variable (or support)?

const Footer = () => { let a="<b>Hey</b>" return ( <div> Some bold text: {a} </div> ) } 

This will only display as Some bold text: <b>Hey</b> . How to get bold text in bold? Variable content is my own, so I don't need to worry about that.

+2
source share
1 answer

You will need to use dangerouslySetInnerHTML

 const Footer = () => { let a= { __html: "<b>Hey</b>" }; return ( <div> Some bold text: <span dangerouslySetInnerHTML={a} /> </div> ) } 
+5
source

All Articles