简体   繁体   中英

Pass props to the component you came from when user clicks back button on window, in React

I am going from component A to component B via routing and I need to pass prop to A when user clicks on the windows back button while on component B. Is there any way of doing this? I am using React's history.push to navigate between components.

You can create a service (it's a singleton) to share state together.

See my example project at here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM