DEV Community

How to make a React / Redux App able to get a value from a sub-component?

sunflowerseed on February 24, 2020

I have this simple Counter using React / Redux: https://stackblitz.com/edit/react-kkcgza?file=App.js It is said that Redux can let any component ...
Collapse
 
keirk profile image
Keir Kettle • Edited

The thing to bear in mind with React is the data flow is top down - App passes data downwards to Counter via props. So if App is interested in the data then either:

  • It could contain the logic (i.e. it becomes the 'container') - see medium.com/@dan_abramov/smart-and-...

  • You could connect the App component to the Redux store (using the connect hoc)