mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
async calls WIP
This commit is contained in:
23
docs/examples/preact/index.js
Normal file
23
docs/examples/preact/index.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/* external */
|
||||
import {h, render} from 'https://unpkg.com/preact?module';
|
||||
|
||||
/* external */
|
||||
import {Stateful} from './stateful.js'
|
||||
|
||||
const Counter = Stateful({
|
||||
getInitialState: () => ({counter: 0}),
|
||||
|
||||
handlers: {
|
||||
inc: ({counter}) => ({counter: counter + 1}),
|
||||
dec: ({counter}) => ({counter: counter - 1}),
|
||||
},
|
||||
|
||||
render: (props, state, handlers) =>
|
||||
h('div', null,
|
||||
h('span', null, state.counter),
|
||||
h('button', {onClick: handlers.inc}, 'Increment'),
|
||||
h('button', {onClick: handlers.dec}, 'Decrement'),
|
||||
)
|
||||
})
|
||||
|
||||
render(h(Counter), globalThis.document.body)
|
||||
Reference in New Issue
Block a user