Can I use inline HTML in a script as below by using a library like jsx:
It looks like the dom-chef package can do this. From the readme:
- No API, JSX gets auto transformed into actual DOM elements.
// babel.config.js const plugins = [ [ '@babel/plugin-transform-react-jsx', { pragma: 'h', pragmaFrag: 'DocumentFragment', } ] ]; // ...
const {h} = require('dom-chef'); const handleClick = e => { // was clicked }; const el = ( ); document.body.appendChild(el);