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

支持使用者自己使用 componentDidCatch 捕获页面异常 #8040

Closed
digiaries opened this issue Nov 16, 2020 · 1 comment
Closed

支持使用者自己使用 componentDidCatch 捕获页面异常 #8040

digiaries opened this issue Nov 16, 2020 · 1 comment
Labels
enhancement New feature or request F-react Framework - React

Comments

@digiaries
Copy link
Contributor

这个特性解决了什么问题?

目前 taro 为了避免在 React 16 中因没有捕获异常导致页面挂掉在 runtime 的实现中定义了 componentDidCatch,而这个函数中并没有判断原始模块中是否已经包含了 componentDidCatch,这导致开发者想自己捕获异常后做一些事情(如错误统计、预警)变得很麻烦。
希望在该函数中加入对原始模块 componentDidCatch 的判断。

这个 API 长什么样?

直接在页面模块中使用 componentDidCatch 捕获异常。

@jeange1003
Copy link

Taro 自动设置错误边界,觉得这样很好。
但是,是否可以让开发者能够关闭自动设置的错误边界,比如通过编译配置来关闭?
目前在做全局的错误监控,也遇到这个问题。
通过 HOC 的方式实现的话,对每个页面的代码有侵入性,提高了业务代码的接入成本。
如果能只需在app级别实现一个componentDidCatch就可以捕获全局错误的话,接入成本能低一些。

@ZakaryCode ZakaryCode added the F-react Framework - React label Apr 14, 2023
@Chen-jj Chen-jj closed this as completed Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request F-react Framework - React
Projects
None yet
Development

No branches or pull requests

4 participants