在开发模式下禁用错误覆盖 [英] Disable error overlay in development mode

查看:181
本文介绍了在开发模式下禁用错误覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发模式下运行create-react-app时是否可以禁用错误覆盖?

Is there a way to disable the error overlay when running a create-react-app in development mode?

这是我正在谈论的覆盖:

This is the overlay I'm talking about:

我问这是因为我使用错误边界(应对16个错误边界)我的应用程序在组件崩溃时显示错误消息,但错误覆盖会弹出并覆盖我的消息。

I'm asking this because im using error boundaries (React 16 Error Boundaries) in my app to display error messages when components crashes, but the error overlay pops up and covers my messages.

推荐答案

提供一个选项来禁用开发中的错误覆盖。
错误边界不会取代(它们仅供生产使用)。

We don't provide an option to disable the error overlay in development. Error boundaries do not take its place (they are meant for production use).

同时开发错误覆盖和错误边界都没有危害;如果您想查看错误边界,只需按 Escape

There is no harm having both the development error overlay and your error boundary; simply press Escape if you'd like to view your error boundary.

我们认为错误叠加层在您的典型错误边界上提供了巨大的价值(源代码,单击以打开等)。
这一点也很重要,因为我们探索了将热组件重新加载作为所有用户的默认行为的方法。

We feel the error overlay provides tremendous value over your typical error boundary (source code, click to open, etc). It is also vital as we explore enabling hot component reloading as a default behavior for all users.

如果您强烈希望禁用覆盖,您将需要从反应脚本中弹出,并停止使用 webpackHotDevClient 。侵入性较小的方法可能是删除由窗口的覆盖层安装的错误事件侦听器。

If you feel strongly about disabling the overlay, you'll need to eject from react-scripts and discontinue use of webpackHotDevClient. A less intrusive method may be removing the error event listener installed by the overlay off of window.

这篇关于在开发模式下禁用错误覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆