私はセレクタを持つコンテナを1つ持っており、他のセレクタを持つ別のコンテナをレンダリングします。再選択 - セレクタで定義されていない小道具
問題点は、2番目の小道具は定義されておらず、すべてが壊れていることです。ここ
は(小道具が第2のセレクタで定義されていない)のコードは次のとおり小道具が未定義復帰
selectProductsState。
ワンセレクター:
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
});
別の容器は、彼自身のセレクタを持っています。
どうすれば修正できますか?あなたは結果関数のparams({ props }
)にundefined
オブジェクトからprops
プロパティを抽出しようとするので、それはおそらく壊れる
おかげ
ありがとう!それはうまくいった! –