UNPKG

901 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 './style.scss';
12import { increase, decrease, double } from './state';
13
14export class App extends React.Component {
15 render() {
16 return (
17 <div className="center-wrapper">
18 <h2>{ this.props.counter.value }</h2>
19 <button onClick={this.props.increase}>+</button>{' '}
20 <button onClick={this.props.decrease}>-</button>{' '}
21 <button onClick={this.props.double}>double</button>
22 </div>
23 );
24 }
25}
26
27App.propTypes = {
28 counter: PropTypes.object,
29 increase: PropTypes.func,
30 decrease: PropTypes.func,
31 double: PropTypes.func
32};
33
34export default connect(
35 state => ({ counter: state.app.counter }),
36 { increase, decrease, double }
37)(App);