Coder Social home page Coder Social logo

valentinogagliardi / react-redux-tutorial Goto Github PK

View Code? Open in Web Editor NEW
122.0 7.0 80.0 2.72 MB

Companion repo for React Redux Tutorial for Beginners

Home Page: https://www.valentinog.com/blog/redux/

License: MIT License

HTML 18.19% CSS 9.73% JavaScript 72.08%
redux redux-thunk redux-saga reactjs

react-redux-tutorial's Issues

Replace mapDispatchToProps object with a function

First of all, thank you very very much for this great tutorial. It is much, much more clear than the redux and react-redux tutorials/documentations combined!

I have a small suggestion: replace { getData } on line 33 of Posts.js with a mapDispatchToProps function that extends the mapDispatchToProps function used up to this point in the tutorial as follows

function mapDispatchToProps(dispatch) {
  return {
    addArticle: article => dispatch(addArticle(article))
    getData: () => dispatch(getData())
  };
}

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(Post);

I'm suggesting this change since it took me a while to figure out why this.props.getData() on line 11 works without a call to dispatch. It is only after I looked at the connect docs that I learned that passing an object instead of a function to connect binds dispatch to each action creator.

Don' get me wrong: it's useful to know about the Object Shorthand Form. It's just that it's a bit much when learning the basics. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.