Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-jsx-to-html

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-jsx-to-html

Transform JSX to HTML.

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
373
decreased by-39.05%
Maintainers
2
Weekly downloads
 
Created
Source

babel-plugin-transform-jsx-to-html

Transform jsx to html string for better ssr performance.

Installation

npm install --save-dev babel-plugin-transform-jsx-to-html

Usage

Via .babelrc

.babelrc

{
  "plugins": [
    "babel-plugin-transform-jsx-to-html",
    "babel/plugin-transform-react-jsx"
  ]
}

Example

basic example

Your component.js that contains this code:

import { createElement, Component } from 'rax';

class App extends Component {
  render() {
    return <div className="header" />
  }
}

Will be transpiled like this:

import { createElement, Component } from 'rax';

class App extends Component {
  render() {
    return [{
      __html: '<div class="header" />'
    }];
  }
}

These pre transpiled html can be used in server renderer, like rax-server-renderer

more examples

input

<div>
  <View />
</div>

output

[{
   __html: "<div>"
}, 
createElement(View, null),
{
  __html: "</div>"
}]

input

<div className="container" style={style} onClick={onClick}>
  <div>a {props.index}</div>
</div>

output

[{
  __html: "<div class=\"container\""
}, {
  __attrs: {
    style: style,
    onClick: onClick
  }
}, {
  __html: "><div>a "
}, props.index, {
  __html: "</div></div>"
}]

FAQs

Package last updated on 11 Jun 2020

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc