1.0.1 • Published 7 years ago

jsx0 v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

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
})

:warning: 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