You can use location
to send state to other component, like this
In your Source Component
this.props.history.push(pathComponent, sendState);
pathComponent
is target component that will receive the state
In your Target Component you can receive the state like this if your use class component
constructor(props) {
this.state = this.props.location.state
}
constructor(props: {}) {
const receiveState = this.props.location.state as StateType // you must parse into your state interface or type
this.state = receiveState
}
If you want to reset the received state. Use history
to replace the location, like this
this.props.history({pathName: currentPath, state: resetState})
currentPath
is the Target Component path
resetState
is new value state whatever you want