Giter Site home page Giter Site logo

Comments (4)

Benouzef avatar Benouzef commented on August 12, 2024

Same issue here.
Any idea ?
thanks for your help

from peckish.

jlebensold avatar jlebensold commented on August 12, 2024

@Benouzef did you use the connect() method from react-redux ? Can you provide sample code or a branch?

from peckish.

Benouzef avatar Benouzef commented on August 12, 2024

Hi @jlebensold,
Thanks for your feedback : I seem to be "messing around" with redux configuration. I have "copied" your app to play around with it and I have a nested component "below" app which is the container (your Home component basically).
I can't get a reference to 'this.props.addRecipe()' if I don't add : connect as well as mapDispatchToProps in the nested component.
I thought I had to pass mapDispatchToProps in the connect call only in the appContainer file.
Am I misunderstanding something or do you have to repeat the "export default connect(mapStateToProps, mapDispatchToProps)(Home)" in each component ?
I thought I could only do "connect(mapStateToProps)(Home)"
Thanks for your advice

from peckish.

jlebensold avatar jlebensold commented on August 12, 2024

Hi @Benouzef ,

There's no "magic" (e.g. IoC containers or DI) with Redux. when you call connect, you are basically wrapping your Home React component in a wrapper component that connects your React component to the Redux store. This is how the props become accessible to your component. In principle, you want to delineate which components are "smart" components that some understanding of global state and which components are "dumb" and just receive props and do whatever they need to do.

from peckish.

Related Issues (12)

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.