There is routing on React-route
render(
<Provider store={store}>
<Router history={browserHistory}>
<Route path='/' component={App}>
<IndexRoute component={Home} />
<Route path='/products' component={Products} />
<Route path='*' component={NoMatch} />
</Route>
</Router>
</Provider>,
document.getElementById('root')
);
Smart App component that is the container
class App extends Component {
render() {
return (
<div className='page-content'>
<Sidebar />
<Content>
{this.props.children} // ---> Here output content from child routes
</Content>
</div>
)
}
}
Here is Products component from which I'm trying to get props.products from the App container. But the Products component does not see the container props App. I think this is because the App is two levels higher
export default class Products extends Component {
constructor(props) {
super(props)
}
loadProducts() {
this.props.getProducts()
}
render() {
console.log(this.props.products); // undefined
return (
<div>
<h3>Products</h3>
</div>
)
}
}
In the container App there is props.products I checked in chrome-dev-tools. But how do you pass it to the Products component?