forked from jorgebucaran/hyperapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (29 loc) · 818 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// to run this, go to the poc folder and run
// npm install -g beefy
// npm install browserify babelify babel-preset-es2015 babel-preset-react
// beefy index.js -- -t [babelify --presets [react es2015] ]
import { app, h, Provider, connect } from '../src/index.js'
// import { h, Provider, connect } from './connect.js'
/** @jsx h */
console.log(1)
const Controls = connect((props, children) => (
<div>
<button onclick={props.context.add}>+</button>
<button onclick={props.context.sub}>-</button>
<p>{props.regularPropsWork}</p>
</div>
))
app({
state: 0,
view: (state, actions) => (
<main>
<Provider context={actions} />
<h1>{state}</h1>
<Controls regularPropsWork="just fine" />
</main>
),
actions: {
add: state => state + 1,
sub: state => state - 1
}
})