Socket
Socket
Sign inDemoInstall

react-jsxstring-to-react

Package Overview
Dependencies
6
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-jsxstring-to-react

React plugin to convert jsx string to react component


Version published
Weekly downloads
4
Maintainers
1
Install size
4.86 MB
Created
Weekly downloads
 

Readme

Source

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.

Keywords

FAQs

Last updated on 11 Feb 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc