I want to redirect to previous page when the current page is reloaded or refreshed,
constructor(props) {
super(props);
this.onUnload = this.onUnload.bind(this);
this.onbeforeunload= this.onbeforeunload.bind(this)
this.state = {
show_answers: [],
other_data: [],
question: "",
answer: "",
id: 0,
};
}
onUnload() {
console.log("reloads")
this.context.router.push('/getanswer');
}
onbeforeunload(){
console.log("reloadsssss")
this.context.router.push('/getanswer');
}
I have tried above way but not working any suggestions.