Tho*_*mes 9 typescript reactjs react-router react-router-dom react-typescript
我已将 React 版本升级到 18,并从 BrowserRouter 组件中收到一些类型错误,尝试了不同的方法,但无法识别问题所在。
下面是我调试代码时的错误,
Overload 1 of 2, '(props: BrowserRouterProps | Readonly<BrowserRouterProps>): BrowserRouter', gave the following error.
Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<BrowserRouter> & Readonly<BrowserRouterProps>'.
Overload 2 of 2, '(props: BrowserRouterProps, context: any): BrowserRouter', gave the following error.
Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<BrowserRouter> & Readonly<BrowserRouterProps>'.
Run Code Online (Sandbox Code Playgroud)
如果能伸出援助之手,我将不胜感激。
我也面临着类似的问题@types/react-router-dom@5.3.0。跑步
npm install @types/react-router-dom@5.3.3
修复。
5.3.3版本中的BrowserRouterProps接口如下所示:
export interface BrowserRouterProps {
basename?: string | undefined;
children?: React.ReactNode;
getUserConfirmation?: ((message: string, callback: (ok: boolean) => void) => void) | undefined;
forceRefresh?: boolean | undefined;
keyLength?: number | undefined;
}
Run Code Online (Sandbox Code Playgroud)
而且5.3.0版本似乎没有可选的children字段。
| 归档时间: |
|
| 查看次数: |
949 次 |
| 最近记录: |