セレクタにクリックされたアイテムの内容を取得できるように、セレクタに小道具を渡す必要があります。しかし、私は小道具を渡すことができませんでした。私はこの方法を試してみましたが、ここでは何の成功小道具をセレクタに渡してその小道具に基づいてフィルタをかける
const mapStateToProps = createStructuredSelector({
features: selectFeatures(),
getFeatureToEditById: selectFeatureToEditById(),
});
handleFeatureEdit = (event, feature) => {
event.preventDefault();
console.log("feature handle", feature);
const dialog = (
<FeatureEditDialog
feature={feature}
featureToEdit={selectFeatureToEditById(feature)}
onClose={() => this.props.hideDialog(null)}
/>
);
this.props.showDialog(dialog);
};
selectors.js
const selectFeatureState = state => state.get("featureReducer");
const selectFeatureById = (_, props) => {
console.log("props", _, props); #if i get the id of feature here
# i could then filter based on that id from below selector and show
# the result in FeatureEditDialog component
};
const selectFeatureToEditById =() =>
createSelector(
selectFeatureState,
selectFeatureById,
(features, featureId) => {
console.log("features", features, featureId);
}
);
は完全なコードのための要旨
https://gist.github.com/MilanRgm/80fe18e3f25993a27dfd0bbd0ede3c20
もっとコードを追加してください。 –
完全なコードで私の質問を更新@SantoshRamKunjir – Serenity