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.

You cannot change <Router routes>; it will be ignored

See original GitHub issue

Hi, I cannot seem to setup the hot reloading. It actually works, but I keep getting the error in console You cannot change <Router routes>; it will be ignored

This is my router file

import React from 'react';
import ReactDOM from 'react-dom';

import {Provider} from 'react-redux';
import {Router, browserHistory} from 'react-router';
import {syncHistoryWithStore} from 'react-router-redux';
import { getRootNode } from '../../helpers/routing_helpers';

// Components

// Hot reload
import { AppContainer as HotLoaderAppContainer } from 'react-hot-loader';
import AppRoutes from './routes';

export default function (inject: Function, {Store}: IContext) {
  const history = syncHistoryWithStore(browserHistory, Store);

  const renderApp = (CurrentAppRoutes: any) => {
    ReactDOM.render(
      <HotLoaderAppContainer>
        <Provider store={Store}>
          <Router history={history}>
            { CurrentAppRoutes }
          </Router>
        </Provider>
      </HotLoaderAppContainer>,
      getRootNode('react-root')
    );
  };

  renderApp(AppRoutes);

  if (module.hot) {
    module.hot.accept('./routes.jsx', () => {
      const NextAppRoutes = require('./routes').default;
      renderApp(NextAppRoutes);
    });
  }
};

And a routes file

import React from 'react';

import {Route, IndexRoute } from 'react-router';

// Components
import Layout from './components/layout';
import HomePage from './components/home_view';
import ProfilePage from '../user/components/profile_view';

const AppRoutes = (
  <Route path="/" component={Layout}>
    <IndexRoute component={HomePage} />
    <Route path="profile" component={ProfilePage} />
  </Route>
);

export default AppRoutes;

Would you be able to help please?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:31 (1 by maintainers)

github_iconTop GitHub Comments

88reactions
thebuildercommented, Sep 8, 2016

My “solution” is to override the console.error, and filter the warning out. It’s only included when HMR is enabled.

/**
 * Warning from React Router, caused by react-hot-loader.
 * The warning can be safely ignored, so filter it from the console.
 * Otherwise you'll see it every time something changes.
 * See https://github.com/gaearon/react-hot-loader/issues/298
 */
if (module.hot) {
  const isString = require('./utils/checks').isString;

  const orgError = console.error; // eslint-disable-line no-console
  console.error = (...args) => { // eslint-disable-line no-console
    if (args && args.length === 1 && isString(args[0]) && args[0].indexOf('You cannot change <Router routes>;') > -1) {
      // React route changed
    } else {
      // Log the error as normally
      orgError.apply(console, args);
    }
  };
}
41reactions
singggum3bcommented, May 27, 2016

I think this issue should this be kept open util it’s officially fixed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting `You cannot change <Router routes>; it will be ignored ...
It looks like it's saying if you're on the current page and the route doesn't change, but everything else stayed the same, then...
Read more >
react-route,react-hot-loader.webpack (You cannot change ...
You cannot change 《Router routes》; it will be ignored. I don't know how to solve this issue.there is code: webpack code: var path...
Read more >
react-route,react-hot-loader.webpack (You cannot change ...
[Solved]-react-route,react-hot-loader.webpack (You cannot change <Router routes>; it will be ignored)-Reactjs ... The router actually should never change, so you ...
Read more >
解決React-Router 在Webpack-dev-server 的HMR (hot-module ...
如果你使用React-Router,那麼一定會搭配Webpack 一起服用吧? ... `You cannot change <Router routes>; it will be ignored` when hot-loading.
Read more >
How to Handle Routing in a React Application using the React ...
So it renders the JSX elements. This path prop is used to identify the portion of the URL that the router should match....
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