UNPKG

943 BJavaScriptView Raw
1// @flow
2/* eslint
3 no-unused-vars: 0
4 react/no-multi-comp: 0
5*/
6import React from 'react';
7import PropTypes from 'prop-types';
8import { connect } from 'react-redux';
9import type { CounterType } from './types';
10
11import { Wrapper, Headline, Button } from './styled.js';
12import { increase, decrease, double } from './state';
13
14class App extends React.Component {
15 props: CounterType;
16 render() {
17 return (
18 <Wrapper>
19 <Headline>{ this.props.counter.value }</Headline>
20 <Button onClick={this.props.increase}>+</Button>{' '}
21 <Button onClick={this.props.decrease}>-</Button>{' '}
22 <Button onClick={this.props.double}>double</Button>
23 </Wrapper>
24 );
25 }
26}
27
28App.propTypes = {
29 counter: PropTypes.object,
30 increase: PropTypes.func,
31 decrease: PropTypes.func,
32 double: PropTypes.func
33};
34
35export default connect(
36 state => ({ counter: state.app.counter }),
37 { increase, decrease, double }
38)(App);