index.jsx 734 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React, { Component, PropTypes } from "react";
  2. import { connect } from "react-redux";
  3. import { increment } from "actions/app";
  4. @connect(state => ({
  5. counter: state.app.get("counter"),
  6. }))
  7. export default class Home extends Component {
  8. static propTypes = {
  9. counter: PropTypes.number,
  10. dispatch: PropTypes.func,
  11. }
  12. constructor() {
  13. super();
  14. this.handleIncrement = this.handleIncrement.bind(this);
  15. }
  16. handleIncrement() {
  17. const { dispatch } = this.props;
  18. dispatch(increment());
  19. }
  20. render() {
  21. const {
  22. counter,
  23. } = this.props;
  24. return (
  25. <div>
  26. <h2>Welcome to Musare!</h2>
  27. <h3>{ counter }</h3>
  28. <button onClick={ this.handleIncrement }>
  29. Increase counter
  30. </button>
  31. </div>
  32. );
  33. }
  34. }