【问题标题】:Typedefs refer to v6 even when using v5即使使用 v5,Typedef 也会引用 v6
【发布时间】:2022-01-08 19:05:41
【问题描述】:

我正在使用 v5 的 react-router-dom。

npm ls --depth=0 | grep 'react-router-dom'
├── @types/react-router-dom@5.3.2
├── react-router-dom@5.3.0

但是,我收到一个错误,例如类型定义引用 v6。

Type '{ exact: true; path: string; component: FC<{}>; }' is not assignable to type 'IntrinsicAttributes & (PathRouteProps | LayoutRouteProps | IndexRouteProps)'.
  Property 'exact' does not exist on type 'IntrinsicAttributes & (PathRouteProps | LayoutRouteProps | IndexRouteProps)'.  TS2322

    93 |           </Header>
    94 |           <ContentBody>
  > 95 |             <Route exact path="/" component={TopPage} />
       |                    ^
    96 |           </ContentBody>
    97 |         </Content>
    98 |       </Container>

我想知道如何在不更新到 v6 的情况下避免这种情况。

【问题讨论】:

    标签: reactjs react-router react-router-dom


    【解决方案1】:

    最近遇到了同样的问题,就我而言,我跑了: npm list react-router 检查它的安装位置。原来它是使用依赖于 v6.1.1 的故事书安装在另一个依赖项中的。 我通过自己安装一个版本的反应路由器解决了这个问题: npm install react-router@5.2.0 --save

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-27
      • 1970-01-01
      • 1970-01-01
      • 2015-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多