Я хочу перенаправить на предыдущую страницу, когда текущая страница перезагружается или обновляется,
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');
}
Я пробовал вышеупомянутый способ, но не работает никаких предложений.