How to embed html file in React?
I had a use -case where I was suppose to add terms & conditions in my project. Initially created a react component & added the terms & conditions content in that file. But then there were unwanted lint errors like max length of line etc.
So then I imported that file, as module export, like below
tnc.js
module.exports. =`<Doctype><html content if terms & condition></Doctype>`
And imported this file in the parent component
tncContent.js
import termsAndCondition from 'tnc.js'
const tncContent=() =>{
return (
<div dangerouslySetInnerHtml={{ _html: termsAndCondition}}>
)
}
Tadda!! Html has been imported & no more sonar lint errors anymore
Thanks for reading.
Feel free to connect me on Twitter, Linkedin