1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import React from 'react';
|
7 | import PropTypes from 'prop-types';
|
8 | import { observer } from 'mobx-react';
|
9 | import type { CounterType } from './types';
|
10 |
|
11 | import './style.css';
|
12 |
|
13 | type Props = {
|
14 | counter: CounterType
|
15 | };
|
16 |
|
17 | @observer
|
18 | class App extends React.Component {
|
19 | props: Props;
|
20 |
|
21 | render() {
|
22 | return (
|
23 | <div className="center-wrapper">
|
24 | <h2>{ this.props.counter.value }</h2>
|
25 | <button onClick={ () => this.props.counter.increase() }>+</button>{' '}
|
26 | <button onClick={ () => this.props.counter.decrease() }>-</button>{' '}
|
27 | <button onClick={ () => this.props.counter.double() }>double</button>
|
28 | </div>
|
29 | );
|
30 | }
|
31 | }
|
32 |
|
33 | App.propTypes = {
|
34 | counter: PropTypes.object
|
35 | };
|
36 |
|
37 | export default App;
|