JSFiddle - React, Tailwind, and code Playground
by de Montalembert Jonathan
JavaScript
const app = (state, actions, view, el) => {
$(el).html(view(state,actions))
}
const h = (node, attr, children) =>{
return $("<"+node+">", attr).append(children)
}
const state = {
count: 0
}
const actions = {
down: value => state => ({ count: state.count - value }),
up: value => state => ({ count: state.count + value })
}
const view = (state, actions) =>
h("div", {}, [
h("h1", {}, state.count),
h("button", { onclick: () => actions.down(1) }, "–"),
h("button", { onclick: () => actions.up(1) }, "+")
])
window.main = app(state, actions, view, document.body)