The vanilla alternative for writing JSX-based React applications
git clone git://soophie.de/figure
blob: 51ee236a6028df9bbc23ca08baf92b45e28e074f (779 bytes)[doc][blame][raw]
1
# figure2
Reactive template literals for React4
### Example6
```javascript7
import figure from '...';9
// initialize figure10
const { dist } = figure({ createElement });12
// add your components to a bundle13
const ElementBundle = {14
button: Button,15
};17
// add your bundles to the dictionary18
const html = dist({19
el: ElementBundle,20
});22
function App() {23
return html`24
<main>25
<el:button26
type="primary"27
on:click=${() => console.log('It works!')}28
>29
<span>Click me</span>30
</el:button>31
</main>32
`;33
}35
function Button() {36
return html`37
<button38
on:click=${props?.onClick}39
class="btn btn--${props?.type}"40
>41
${props?.children}42
</button>43
`;44
}46
render(createElement(App), document.querySelector('#root'));47
```