react-jsxstring-to-react
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

React JSXString to React Component

npm version ts version github release license NPM Downloads

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.

/react-jsxstring-to-react/

    Package Sidebar

    Install

    npm i react-jsxstring-to-react

    Weekly Downloads

    4

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    22.2 kB

    Total Files

    18

    Last publish

    Collaborators

    • gihan.rangana