index.jsx 759 B

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