Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复 forwardRef 组件的错误无法捕获 #2544

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

rainke
Copy link
Contributor

@rainke rainke commented Oct 11, 2023

描述问题

普通函数组件报错(比如需要绑定一个数组绑定成了数字)修改配置后可以恢复
image
forwardRef 组件报错,比如需要绑定一个数组绑定成了数字)修改配置后无法恢复(修要手动执行 simulatorHost.rerender()才能恢复)
image

修复的问题

  1. 如果物料组件不能接受 ref,就包裹一个类组件
    } else if (isReactComponent(component)) {
    if (!acceptsRef(component)) {
    component = wrapReactClass(component as FunctionComponent);
    }
    components[componentName] = component;
  2. 原有的 patchDidCatch 逻辑只对类组件生效,这会导致 forwardRef 的组件无法捕获错误

如何修复

针对 forwardRef 进行特殊处理

@rainke rainke marked this pull request as draft October 11, 2023 07:30
@rainke rainke force-pushed the patch-5 branch 3 times, most recently from 6c8b1a5 to d2258e3 Compare October 11, 2023 08:12
@rainke rainke marked this pull request as ready for review October 11, 2023 08:16
@rainke rainke marked this pull request as draft October 11, 2023 08:20
@rainke rainke force-pushed the patch-5 branch 5 times, most recently from e69c0a6 to 7d0a9b9 Compare October 11, 2023 09:40
@rainke rainke marked this pull request as ready for review October 11, 2023 09:54
@rainke rainke force-pushed the patch-5 branch 2 times, most recently from 319eec6 to f41d95c Compare October 12, 2023 06:36
@liujuping liujuping merged commit ca6fe7c into alibaba:develop Oct 16, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants