[英]can we pass a value when we move to next component using this.props.history.push("/next Component")?
I want to send Task_id to the ShowRecommendation.js component我想将Task_id发送到ShowRecommendation.js组件
recommend = Task_id => {
this.props.history.push("/ShowRecommendation");
};
How it can be done?怎么做?
With react-router you can transfer "state"使用 react-router,您可以传输“状态”
this.props.history.push({
pathname: '/ShowRecommendation',
state: { taskid: Task_id }
})
and at the ShowRecommendation.js componenet you can get the value using在 ShowRecommendation.js 组件中,您可以使用以下方法获取值
console.log(this.props.location.state)
Comment if you have more questions如有更多问题请留言
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.