How to use the react-error-overlay.startReportingRuntimeErrors function in react-error-overlay

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 your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeit / next.js / packages / next / client / dev / error-overlay / hot-dev-client.js View on Github external
const resolvedFilename = fileName.replace(/^webpack:\/\//, '')
    fetch(
      '/_next/development/open-stack-frame-in-editor' +
        `?fileName=${window.encodeURIComponent(resolvedFilename)}` +
        `&lineNumber=${lineNumber || 1}` +
        `&colNumber=${colNumber || 1}`
    )
  })

  // We need to keep track of if there has been a runtime error.
  // Essentially, we cannot guarantee application state was not corrupted by the
  // runtime error. To prevent confusing behavior, we forcibly reload the entire
  // application. This is handled below when we are notified of a compile (code
  // change).
  // See https://github.com/facebook/create-react-app/issues/3096
  ErrorOverlay.startReportingRuntimeErrors({
    onError: function() {
      hadRuntimeError = true
    },
  })

  if (module.hot && typeof module.hot.dispose === 'function') {
    module.hot.dispose(function() {
      // TODO: why do we need this?
      ErrorOverlay.stopReportingRuntimeErrors()
    })
  }

  getEventSourceWrapper(options).addMessageListener(event => {
    // This is the heartbeat event
    if (event.data === '\uD83D\uDC93') {
      return
github lnlfps / symph-joy / client / dev-error-overlay / hot-dev-client.js View on Github external
const resolvedFilename = fileName.replace(/^webpack:\/\//, '')
    fetch(
      '/_joy/development/open-stack-frame-in-editor' +
        `?fileName=${window.encodeURIComponent(resolvedFilename)}` +
        `&lineNumber=${lineNumber || 1}` +
        `&colNumber=${colNumber || 1}`
    )
  })

  // We need to keep track of if there has been a runtime error.
  // Essentially, we cannot guarantee application state was not corrupted by the
  // runtime error. To prevent confusing behavior, we forcibly reload the entire
  // application. This is handled below when we are notified of a compile (code
  // change).
  // See https://github.com/facebook/create-react-app/issues/3096
  ErrorOverlay.startReportingRuntimeErrors({
    onError: function () {
      hadRuntimeError = true
    }
  })

  if (module.hot && typeof module.hot.dispose === 'function') {
    module.hot.dispose(function () {
      // TODO: why do we need this?
      ErrorOverlay.stopReportingRuntimeErrors()
    })
  }

  getEventSourceWrapper(options).addMessageListener((event) => {
    // This is the heartbeat event
    if (event.data === '\uD83D\uDC93') {
      return
github react-cosmos / react-cosmos / packages / react-cosmos / src / plugins / webpack / client / errorOverlay / reactErrorOverlay.ts View on Github external
export function init() {
  ErrorOverlay.startReportingRuntimeErrors({
    filename: process.env.PUBLIC_URL + '/main.js'
  });
  ErrorOverlay.setEditorHandler(errorLocation =>
    window.fetch(getLaunchEditorUrl(errorLocation))
  );
  setUpBuildErrorReporting();
}