bourbon-vanilla
v1.0.1
Published
A library to use JSX with vanilla Javascript
Readme
Bourbon Vanilla
Hi!
Ever want to write vanilla JS but miss JSX? Today is your day!
Example
This is what it looks like to use Bourbon Vanilla:
function App() {
let count = 0;
let countSpan = <span>{count}</span>;
function setCount(newCount) {
count = newCount;
countSpan.textContent = count;
}
return (
<div>
<p>Count: {countSpan}</p>
<button onClick={(e) => setCount(count + 1)}>+</button>
<button onClick={(e) => setCount(count - 1)}>-</button>
</div>
);
}
const root = document.getElementById("root");
root.appendChild(<App />);And here's one way to compile this:
esbuild src/main.jsx \
--jsx-import-source=bourbon-vanilla \
--jsx=automaticOther bundlers should support something similar.
Install
npm install bourbon-vanillaThat's everything! 🥳
