display raw html as plain text react js

Solutions on MaxInterview for display raw html as plain text react js by the best coders in the world

showing results for - "display raw html as plain text react js"
Aurélien
06 Feb 2016
1I have tried this pure component:
2
3const RawHTML = ({children, className = ""}) => 
4<div className={className}
5  dangerouslySetInnerHTML={{ __html: children.replace(/\n/g, '<br />')}} />
6Features
7
8Takes classNameprop (easier to style it)
9Replaces \n to <br /> (you often want to do that)
10Place content as children when using the component like:
11<RawHTML>{myHTML}</RawHTML>
12I have placed the component in a Gist at Github: RawHTML: ReactJS pure component to render HTML
13
14Share