gpt4 book ai didi

javascript - 导入错误 : 'useNavigate' is not exported from 'react-router-dom'

转载 作者:行者123 更新时间:2023-12-05 00:25:17 26 4
gpt4 key购买 nike

尝试导入时 useNavigate来自 react-router-dom ,我收到以下错误:

Attempted import error: 'useNavigate' is not exported from 'react-router-dom'.
我的进口声明:
import { useNavigate } from 'react-router-dom';

最佳答案

您正在尝试使用 react-router 的最新功能.
请确保您安装了 react-router-dom@6.0.0-alpha.2 .

It is React Router v6 which gives you a useNavigate hook


refer here for further reading from the React Router team
两种快速检查版本的方法:
  • package.json 验证文件
  • 运行npm list --depth=0查看项目中的各种包
  • 关于javascript - 导入错误 : 'useNavigate' is not exported from 'react-router-dom' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64224629/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com