问题
I want to send Task_id to the ShowRecommendation.js component
recommend = Task_id => {
this.props.history.push("/ShowRecommendation");
};
How it can be done?
回答1:
With react-router you can transfer "state"
this.props.history.push({
pathname: '/ShowRecommendation',
state: { taskid: Task_id }
})
and at the ShowRecommendation.js componenet you can get the value using
console.log(this.props.location.state)
Comment if you have more questions
来源:https://stackoverflow.com/questions/59095211/can-we-pass-a-value-when-we-move-to-next-component-using-this-props-history-push