Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

javascript - 当我们使用this.props.history.push(“ / next Component”)移至下一个组件时,我们可以传递一个值吗?(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?(怎么做?)   ask by Eisha Mazhar translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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(如果您还有其他问题请发表评论)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...