New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

react-to-jsx

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-to-jsx

Generates a JSX string representation of React elements


Version published
Weekly downloads
484
increased by23.16%
Maintainers
1
Weekly downloads
 
Created

React to JSX

Generates a JSX string representation of React elements. Takes a React Element (or an array of React Elements). Useful for generating React component style guides.

Usage

Install

npm install react-to-jsx

Basic Usage

var reactToJsx = require('react-to-jsx');

var jsxString = reactToJsx(
  <Button
    type="submit"
    size="large">
    Cool Button
  </Button>
);

// <Button
//   type="submit"
//   size="large">
//   Cool Button
// </Button>

console.log(jsxString);

Options

reactToJsx takes an optional options object: reactToJsx(reactElement, options).

indent

Type: String Default: '\t' (Tab)

Sets the indent string for returned JSX. Should probably match your preferred code style. Two spaces? Four? Three? The choice is yours, friend.

includeNull

Type: 'Boolean' Default: true

Determines whether to include props with a value of null in the returned JSX.

exclude

Type: Array Default: []

Array of props to exclude from the returned JSX. Hide those weird props, they shouldn't be in your docs anyway.

FAQs

Package last updated on 11 Jun 2015

Did you know?

Socket

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