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
.babelrc
Via .babelrc
Example
basic example
Your component.js
that contains this code:
; { return <div className="header" /> }
Will be transpiled like this:
; { 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>" __html: "</div>"
input
<div ="container" = => <div>a propsindex</div></div>
output
__html: "<div class=\"container\"" __attrs: style: style onClick: onClick __html: "><div>a " propsindex __html: "</div></div>"