我需要将道具传递给选择器,以便我可以从选择器中获取点击项目的内容。然而我无法通过道具。我想这样,但没有成功将道具传递给选择器以基于该道具进行过滤
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