react-inner-html
A little helper for simpler dangerouslySetInnerHTML using the spread operator.
Before:
{ return <div = />;}
After:
import html from 'react-inner-html'; { return <div />;}
Or, if you get your html component through a prop, which was the case for me, it gets even simpler:
import html from 'react-inner-html'; { return <div />;}
Remember:
Setting HTML from code is risky because it's easy to inadvertently expose your users to a cross-site scripting (XSS) attack.
So, use it carefully.
Installation:
npm:
npm i -S react-inner-html
yarn:
yarn add react-inner-html