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

React怎么做错误处理? #33

Open
nmsn opened this issue Mar 26, 2023 · 1 comment
Open

React怎么做错误处理? #33

nmsn opened this issue Mar 26, 2023 · 1 comment
Labels

Comments

@nmsn
Copy link
Contributor

nmsn commented Mar 26, 2023

如题

@nmsn nmsn added the React label Mar 26, 2023
@nmsn
Copy link
Contributor Author

nmsn commented Mar 26, 2023

try/catch

手动对执行事件外面套 try/catch

缺点:事无巨细,完全手动控制

ErrorBoundary

创建 ErrorBoundary 组件,捕获内部组件的错误

存在的问题:错误发生在组件声明周期意外不能捕获(例如接口报错)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant