react-jsxstring-to-react is a plugin for React to generate jsx component using strings. follow this example
npm install react-jsxstring-to-react
or
yarn add react-jsxstring-to-react
const jsxString = `<div className="outer">
<p className="test" style={{"color":"#f00"}}>Your Content</p>
</div>`
function App () {
const [elements, setElements] = useState([])
const jsx = useJSX(jsxString)
useEffect(() => {
setElements(jsx.convert())
}, [])
return (
<div>
{elements && elements.map(e => {
return e;
})}
</div>
)
}
Copyright © 2023 Gihan Rangana Released under the MIT license.