This plugin converts JSX into Tagged Templates that work with strve.
// input:
const state = {
count: 0,
};
const Hello = () => <h1 $key>{state.count}</h1>;
// output:
h`<h1 $key>${state.count}</h1>`;
In your Babel configuration (.babelrc
, babel.config.js
, "babel"
field in package.json, etc), add the plugin:
{
"plugins": [
["babel-plugin-jsx-to-strve"]
]
}
By default, babel-plugin-jsx-to-strve
will process all Tagged Templates with a tag function named h
. To use a different name, use the tag
option in your Babel configuration:
{"plugins":[
["babel-plugin-jsx-to-strve", {
"tag": "html"
}]
]}
Copyright (c) 2023-present, maomincoding