我需要將道具傳遞給選擇器,以便我可以從選擇器中獲取點擊項目的內容。然而我無法通過道具。我想這樣,但沒有成功將道具傳遞給選擇器以基於該道具進行過濾
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