Skip to content

Instantly share code, notes, and snippets.

@clucasalcantara
Last active February 26, 2018 11:47
Show Gist options
  • Save clucasalcantara/ba93fe03386a7b71f1041187cb10d52a to your computer and use it in GitHub Desktop.
Save clucasalcantara/ba93fe03386a7b71f1041187cb10d52a to your computer and use it in GitHub Desktop.
Temporary solution to fix a unexpected console error using HMRE
if (isDevelopment && module.hot) {
// Hot module reload for App and its routes.
module.hot.accept('./pages/buildRoutes', () =>
renderApp({ routes: buildRoutes() })
);
// While HMRE works, react-router does a `console.error()` because its routes prop changed.
// We monkey-patch `console.error()` to ignore that error.
// See: https://github.com/gaearon/react-hot-loader/issues/298
// See: https://github.com/ReactTraining/react-router/issues/2704
const originalError = console.error;
console.error = (...args) => {
const [message] = args;
if (typeof message !== 'string' || !message.includes('You cannot change <Router routes>;')) {
originalError.apply(console, args);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment