App.js 729 B

123456789101112131415161718192021222324252627282930
  1. import React from "react";
  2. import {connect} from "react-redux";
  3. import {bindActionCreators} from "redux";
  4. import Hello from "./../components/Hello";
  5. import * as actions from "./../actions";
  6. class App extends React.Component {
  7. constructor(props) {
  8. super(props);
  9. }
  10. render() {
  11. return (
  12. <Hello name={this.props.name} color={this.props.color} newName={this.props.newName} newBackground={this.props.newBackground} />
  13. );
  14. }
  15. }
  16. const mapStateToProps = state => {
  17. return {
  18. name: state.hello,
  19. color: state.color
  20. };
  21. };
  22. const mapDispatchToProps = dispatch => {
  23. return bindActionCreators(actions, dispatch);
  24. };
  25. export default connect(mapStateToProps, mapDispatchToProps)(App);