当我在使用 history.push 导航到如下所示的页面后单击后退按钮时,我正在开发一个 ionic react 应用程序
history.push({
pathname: '/mutiplequiz',
state:
{
testUser,
testTime,
testSubjects
}
})
在 Mutiplequiz 页面上,当我按后退按钮时出现此错误
这是 multiplequiz 页面上的代码
import React ,{useRef,useEffect,useState} from 'react';
import { IonButtons, IonContent, IonHeader,IonIcon, IonMenuButton, IonTitle, IonToolbar,IonImg,IonButton,isPlatform, IonGrid,IonRow,IonCard,IonCardContent,IonCol, IonList,IonItem,IonLabel,IonListHeader, IonLoading, IonSpinner, IonAlert } from '@ionic/react';
import { History, LocationState } from "history";
import { Link, useHistory, } from "react-router-dom";
export type historyData={
testSubjects:[],
year:number,
testTime:number,
testUser:string
}
const MutipleQuiz: React.FC = () => {
const history: History<historyData>= useHistory();
const { testSubjects,testTime,testUser }= history.location.state;
useEffect( ()=>{
},[]);
}
export default MutipleQuiz;
如何返回而不出现此错误