fallbackRender={FullPageErrorFallback} 报错

来源:7-5 实现Error Boundaries,捕获边界错误

raymondJ

2021-12-21

老师你好,我在调用ErrorBoundary的时候,fallbackRender报错如下

No overload matches this call.
Overload 1 of 2, ‘(props: ErrorBoundaryProps | Readonly): ErrorBoundary’, gave the following error.
Type ‘{ children: Element; fallbackRender: ({ error }: { error: Error | null; }) => Element; }’ is not assignable to type ‘IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<…>’.
Property ‘fallbackRender’ does not exist on type ‘IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<…>’.
Overload 2 of 2, ‘(props: ErrorBoundaryProps, context: any): ErrorBoundary’, gave the following error.
Type ‘{ children: Element; fallbackRender: ({ error }: { error: Error | null; }) => Element; }’ is not assignable to type ‘IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<…>’.
Property ‘fallbackRender’ does not exist on type ‘IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<…>’.ts(2769)

写回答

2回答

慕函数1077132

2022-03-31

我遇到这个问题是因为错误引用了 antd 的 ErrorBoundary。 改成自定义的 component 之后就解决了

0
0

小狼baby

2022-01-01

给FullPageErrorFallback的返回类型写成any就不报错了

0
0

React17+Hook+TS4 优质实践,仿 Jira 企业级项目

解锁 React17 高阶用法,轻松应对大型复杂长周期项目

2691 学习 · 1236 问题

查看课程