A 3kb runtime jsx parser. Write your jsx with tagged template literals.
lit-jsx is inspired by lit-html and styled-components.
Demo
Syntax
The syntax of lit-jsx is similar to JSX. Here are differences.
- You should use
${}
to pass value rather than{}
. - Component should pass in
${}
. - you should use
...${obj}
to pass spread attributes rather than{...obj}
. - if closing tag is passed by
${}
, it will be ignored.</${tag}>
is sames as</>
.
Example
HelloMessage
// jsxComponent { return <div>Hellothispropsname</div>; } ReactDOM;
// lit-jsxconst jsx = ; Component { return jsx`<div>Hello,</div>`; } ReactDOM;
Timer
// some editor will recognise html tag function and highlight the code.const html = ; Component { superprops; thisstate = items: text: "" ; thishandleChange = thishandleChange; thishandleSubmit = thishandleSubmit; } { return html` TODO < items= /> What needs to be done? Add # `; } { this; } { e; if !thisstatetextlength return; const newItem = text: thisstatetext id: Date ; this; } Component { return html` `; }