尝试导入错误:“Outlet”未从“react-router-dom”导出

时间:2021-01-09 05:27:01

标签: javascript reactjs react-router-dom

我收到此错误尝试导入错误:“出口”未从“react-router-dom”导出

如果我评论出口,它会抛出尝试导入错误:“开关”未从“react-router-dom”导出

我的 package.json 是

{
  "name": "react-shoe-store-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.11.2",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "axios": "^0.21.1",
    "history": "^5.0.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router": "^6.0.0-beta.0",
    "react-router-dom": "^6.0.0-beta.0",
    "react-scripts": "4.0.1",
    "react-slick": "^0.27.13",
    "slick-carousel": "^1.8.1",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

我已经安装了 react-router-dom v6 但我无法配置这个错误

1 个答案:

答案 0 :(得分:0)

我找不到任何关于 Outlet 的信息,但是 Switch 是从 react-router 而不是 react-router-dom 导出的,see here

import { Switch } from "react-router";