JSFiddle - React, Tailwind, and code Playground

hyperapp qr

by Warwick Grigg

HTML

<script src="https://unpkg.com/[email protected]"></script>
<div id="app">

</div>

Babel + JSX

const { h, app } = hyperapp
/** @jsx h */

const dt = () => { return new Date(Date.now()).toISOString() };

const state = { o1: {}, o2: {} };

const actions = { o1: dt => (s, a) => { 
		// s.o2.a = dt; // mutates s, state and hyperapp's state
  	return {
    	o1: {
      	a: dt,
      },
      f:  a => a,
      // callerState: state
    }; // proper state update  
  },
}

const view = (state, actions) => {
  console.log("render");
  return h("div", {}, [
    h("button", {onclick: e => actions.o1(dt())}, "o1"),
    h("pre", {}, JSON.stringify(state, null, 2)),
    h("pre", {}, state.f || "")
  ]);
}

const main = app(state, actions, view, document.getElementById("app"));