Last active
February 26, 2018 11:47
-
-
Save clucasalcantara/ba93fe03386a7b71f1041187cb10d52a to your computer and use it in GitHub Desktop.
Temporary solution to fix a unexpected console error using HMRE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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