Skip to content

Instantly share code, notes, and snippets.

@glennreyes
Created October 22, 2016 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennreyes/48f8b2f4e6b5d9399ca92e13e07dbedd to your computer and use it in GitHub Desktop.
Save glennreyes/48f8b2f4e6b5d9399ca92e13e07dbedd to your computer and use it in GitHub Desktop.
Example using redbox-react
/* @flow */
/* eslint-disable global-require, no-console */
import React from 'react';
import { render } from 'react-dom';
import Redbox from 'redbox-react';
const clearConsole = () => {
if (typeof console.clear === 'function') {
console.clear();
}
};
const renderApp = () => {
clearConsole();
require('../src');
};
const renderErrorWithRedbox = (error) => {
render(
<Redbox error={error} />,
document.getElementById('root'),
);
console.error(error);
};
try {
renderApp();
} catch (error) {
renderErrorWithRedbox(error);
}
if (module.hot && typeof module.hot.accept === 'function') {
// Enable webpack HMR and just rerun this module
module.hot.accept();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment