sato0203 / hyperapp-react-hooks

Trying to build Hyperapp syntax with simple react hooks

Home Page:https://codesandbox.io/s/github/lemol/hyperapp-react-hooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hyperapp-react-hook

Trying to build Hyperapp syntax with simple react hooks.

Edit 6joor0no6w

Use

yarn         # OR npm install
yarn start   # OR npm start

Result

With create-react-app, based on the Hyperapp getting started counter example, just:

  1. Import React instead of h.

  2. Replace onclick to onClick.

import { React, app } from "./hyperapp"

const state = {
  count: 0
}

const actions = {
  down: value => state => ({ count: state.count - value }),
  up: value => state => ({ count: state.count + value })
}

const view = (state, actions) => (
  <div>
    <h1>{state.count}</h1>
    <button onClick={() => actions.down(1)}>-</button>
    <button onClick={() => actions.up(1)}>+</button>
  </div>
)

app(state, actions, view, document.body);

About

Trying to build Hyperapp syntax with simple react hooks

https://codesandbox.io/s/github/lemol/hyperapp-react-hooks


Languages

Language:HTML 56.7%Language:JavaScript 43.3%