I have one container with its selectors and It renders another container that has its other selectors.
The problem with that is that the second one, props are undefined and it breaks everything.
Here's the code (where props are undefined in the second selector):
selectProductsState props returning undefined.
One selector:
const selectProductsState = () => ({ products }, props) => { return { products, props } };
const getCurrentProductFromParams = () => createSelector(
selectProductsState(),
getProductsItems(),
({ props }, items) => {
const id = extractId(props.params);
return items[id];
}
);
ProductContainer:
class ProductPage extends React.Component {
render() {
return (<OtherContainer />)
}
}
const mapStateToProps = createStructuredSelector({
hasLoadingErrors: getHasLoadingErrors(),
productNotFound: getProductNotFound(),
product: getProduct(),
getCurrentProductFromParams
});
Another container has his own selectors.
How can I fix that?
Thanks
The problem was with the
params
prop passed fromreact-router
to theProductPage
container.So
params
it's not passed down to theOtherContainer
automatically, therefore, params it'sundefined
The solution is passing manually the prop to
OtherContainer
: