3.0.0 • Published 5 years ago

jsx-string v3.0.0

Weekly downloads
174
License
MIT
Repository
github
Last release
5 years ago

JSX-String

JSX-string is a cool module that allows you to write JSX and receive strings out of it. The main benefits include writing XML as JSX.

Because React by design doesn't support colons (:) in attribute and tags, just write a_b and it'll be converted to a:b

Installation

npm install --save jsx-string

Types

export type Options = {
  escape: boolean = false,
};
export default function jsx(input: any, options: Options);
export function h(...);

Usage

import jsxString, { h } from 'jsx-string'

/** @jsx h */
// ^ tell babel to route all JSX calls to that function

const username = 'someone'
const query = jsxString(
  <methodCall>
    <param>{username}</param>
  </methodCall>,
  {
    escape: false,
  },
)
console.log(typeof query) // 'string'

License

This project is licensed under the terms of MIT License, see the LICENSE file for more info