1.0.10 • Published 6 years ago
jsx-serializers v1.0.10
jsx-serializers
collection of jsx serializers which can be injected by using the jsxstatement when compiling with babel
Usage
This module does currently only work with babel. Install the necessary presets:
npm install --save-dev babel-cli babel-polyfill babel-preset-env babel-preset-react
Then create a .babelrc
file to configure the presets:
{
"presets": ["env", "react"]
}
Install this module:
npm install jsx-serializers --save
You are now ready to use the custom jsx-serializers
:
/** @jsx renderHTMLDomTree */ // <- specifies which rendering engine to use
import { renderHTMLDomTree } from "jsx-serializers";
const htmlUserFragment = function (_id, _name) {
return (<div>
<h2>{_name}</h2>
<p>{_id}</p>
</div>);
};
You can do the very same but serialize it to JSON using renderJSONDomTree
. More serializers are soon to come.