react-jsxstring-to-react
v1.0.1
Published
React plugin to convert jsx string to react component
Downloads
9
Maintainers
Readme
React JSXString to React Component
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>
)
}
License
Copyright © 2023 Gihan Rangana Released under the MIT license.