使用React useHistory时遇到错误:Object is of type 'unknown',请大佬指教。
项目版本信息如下:
Node version: v12.14.1
React version: 17.0.1
react-router-dom version: 16.9.8
@types of react-router-dome version: ^5.1.6
使用过程
import { useHistory } from "react-router-dom";
const history = useHistory();
useEffect(() => {
if (history.location.state) {
const taskId: any = history.location.state.taskId
getItemList(taskId)
}
}, [])
// Error message
Object is of type 'unknown'. TS2571
252 | useEffect(() => {
253 | if (history.location.state) {
> 254 | const taskId: any = history.location.state.taskId
| ^
257 | }
https://stackoverflow.com/que...