Skip to content

lemol/hyperapp-react-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published