question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to disable React error overlay?

See original GitHub issue

I find the react-error-overlay useless because the same info and stack trace is in my console and the error overlay is super slow and blocking browser UI as it loads the stack traces. How do I disable it?

I have tried:

// gatsby-browser.js
import { setConfig } from 'react-hot-loader';

setConfig({ ErrorOverlay: () => null });

window.addEventListener('error', (e) => {
  e.stopImmediatePropagation();
  e.preventDefault();
});

which was supposed to work? but does nothing.

Any thoughts? Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

3reactions
nolandgcommented, Jan 7, 2020

Ok, I have a workable solution now. And it sure makes debugging errors snappier without this overlay. Chrome dev tools was bogging for many seconds parsing the sources lines etc. and totally blocking debugger UI and my OS.

I created a folder in my project react-error-overlay and the index.js file in there exports all the required functions and does nothing:

module.exports = {
  setEditorHandler: () => { },
  reportBuildError: () => { },
  reportRuntimeError: () => { },
  dismissBuildError: () => { },
  startReportingRuntimeErrors: () => {},
  dismissRuntimeErrors: () => { },
  stopReportingRuntimeErrors: () => { },
};

and pointed the Gatsby webpack alias plugin there:

// gatsby-config.js
plugins: [
    {
      resolve: 'gatsby-plugin-root-import',
      options: {
        src: path.join(__dirname, 'src'),
        '~': path.join(__dirname),
        'react-error-overlay': path.join(__dirname, 'your-project/react-error-overlay'),
      },
    },
]

After clearing the cache and restarting it took this file instead and now doesn’t bog on every error.

0reactions
pedroBruno7commented, Nov 17, 2021

I think I found a good CSS only solution to disable the error overlay (the modal) on gatsby. This does not work because on gatsby the html is completely different

I added to my global css:

gatsby-fast-refresh {
  display: none !important;
}

body {
  padding: 0 !important;
  overflow: auto !important;
}

For my goal it was perfect. I wanted to not display the error overlay when the error was caught by an Error Boundary. With this CSS solution, the overlay will not appear when the Error Boundary catches the error, but when there is no Error Boundary, the screen goes full white, alerting the developer there is an error

Read more comments on GitHub >

github_iconTop Results From Across the Web

create react app - Disable error overlay in development mode
The error overlay can be disabled by using the stopReportingRuntimeErrors helper utility in the react-error-overlay package ...
Read more >
a-kon/disable-react-error-overlay - GitHub
Description. A tiny library to disable annoying the create-react-app's errors' overlay. Do not use it in production mode!
Read more >
How to get an error overlay with React Hot Loader - Jakob Lind
How to enable react error overlay for React Hot Loader. First, make sure you are using version 2.2.1 of webpack-dev-server. If you don't,...
Read more >
disable-react-error-overlay - npm
Start using disable-react-error-overlay in your project by running `npm i disable-react-error-overlay`. There are no other projects in the ...
Read more >
How to use the react-error-overlay/middleware function in ...
To help you get started, we've selected a few react-error-overlay examples, based on popular ways it is used in public projects. ... Secure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found