The vanilla alternative for writing JSX-based React applications
git clone git://soophie.de/figure
blob: aa438bff44342a8f3fc6cb576345b47981b5926f (786 bytes)[doc][blame][raw]
1
# figure2
Reactive template literals for React4
### Example6
```javascript7
import figure from '...';9
// initialize figure10
const { dict } = figure(React.createElement);12
// add your component to the dictionary13
const html = dict({14
el: {15
button: Button,16
},17
});19
function App() {20
return html`21
<main>22
<el:button23
type="primary"24
on:click=${() => console.log('It works!')}25
>26
<span>Click me</span>27
</el:button>28
</main>29
`;30
}32
function Button() {33
return html`34
<button35
on:click=${props?.onClick}36
class="btn btn--${props?.type}"37
>38
${props?.children}39
</button>40
`;41
}43
// render your App component as usual44
const root = document.querySelector('#root');45
ReactDOM.render(React.createElement(App), root);46
```