1
1
mirror of https://github.com/c8r/x0.git synced 2024-09-11 13:45:52 +03:00
x0/demo/count.js
2018-05-26 10:18:49 -04:00

32 lines
647 B
JavaScript

import React from 'react'
import { Link } from 'react-router-dom'
export default class extends React.Component {
static getInitialProps = async () => {
return {
asyncProps: 'hello'
}
}
render () {
const {
count,
update
} = this.props
return (
<div>
<Link to='/'>Home</Link>
<Link to='/about'>About</Link>
<h1>Hello x0</h1>
<samp>{count}</samp>
<button onClick={e => update(dec)}>-</button>
<button onClick={e => update(inc)}>+</button>
</div>
)
}
}
const dec = s => ({ count: s.count - 1 })
const inc = s => ({ count: s.count + 1 })