123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import React, { Component, PropTypes } from "react";
- import { connect } from "react-redux";
- import { increment } from "actions/app";
- @connect(state => ({
- counter: state.app.get("counter"),
- }))
- export default class Home extends Component {
- static propTypes = {
- counter: PropTypes.number,
- dispatch: PropTypes.func,
- }
- constructor() {
- super();
- this.handleIncrement = this.handleIncrement.bind(this);
- }
- handleIncrement() {
- const { dispatch } = this.props;
- dispatch(increment());
- }
- render() {
- const {
- counter,
- } = this.props;
- return (
- <div>
- <h2>Welcome to Musare!</h2>
- <h3>{ counter }</h3>
- <button onClick={ this.handleIncrement }>
- Increase counter
- </button>
- </div>
- );
- }
- }
|