jsx0

1.0.1 • Public • Published

jsx0

JSX string to React component converter

npm i jsx0
import jsx0 from 'jsx0'
 
const src = `<h1>{props.children}</h1>`
 
const Heading = jsx0(src)
 
// <Heading>Hello</Heading>

Scope

An object of scoped variables can be passed as a second argument for things like creating composite components.

import React from 'react'
import jsx0 from 'jsx0'
 
const Box = props => <div {...props} />
const Image = props => <img {...props} />
const Text = props => <p {...props} />
 
const Card = jsx0(`
<Box>
  <Image src={props.image} />
  <Text children={props.text} />
</Box>`, {
  Box,
  Image,
  Text
})

⚠️ Security

This is dangerous to use with user-generated content and in web applications. This library is primarily intended for sandboxed Node.js environments.

MIT License

Readme

Keywords

Package Sidebar

Install

npm i jsx0

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • jxnblk