hyperapp actions - no wrapper

hyperapp actions - no wrapper

HTML

<script src="https://unpkg.com/hyperapp"></script>
<div id="app">

</div>

Babel + JSX

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

const state = {
  value: 'sample',
  hint: '...',
}

const actions = {
	showHint: hint => {
  	return { hint };
  },
  changeState: e => {
  	let value = e.target.value;
    if(value !== 'hui') return { ...actions.showHint(`isn\'t hui but ${value}`), value };
    
    value = 'Bingo!';
  	return { ...actions.showHint('is hui'), value };
  },
}

const view = (state, actions) => (
<div>
  <h3>type hui</h3>
  <input value={state.value} oninput={actions.changeState} />
  <div>value: {state.value}</div>
  <div>{state.hint}</div>
</div>
)

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