Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Doesn't work with React-Router :( #128

Closed
mdebbar opened this issue Apr 8, 2016 · 5 comments
Closed

Doesn't work with React-Router :( #128

mdebbar opened this issue Apr 8, 2016 · 5 comments

Comments

@mdebbar
Copy link

mdebbar commented Apr 8, 2016

I started using hot reloading and it gave me a huge productivity boost. Thanks everyone for making this possible!

The only problem I'm having now is that route components can't be hot-updated. I'm getting the following warning in my console:

The following modules couldn't be hot updated: (Full reload needed) ...

class MyRouteComponent extends React.Component {
  // ... any changes here can't be hot-updated :(
}

ReactDOM.render(
  <Router>
    <Route path="/" component={MyRouteComponent} />
  </Router>,
  document.body
);

Is there any workaround to make it work?

@gaearon
Copy link
Owner

gaearon commented Apr 8, 2016

Are you writing everything in a single file? Hot reloading will only work if you split the root component into a separate module.

@mdebbar
Copy link
Author

mdebbar commented Apr 9, 2016

Not in a single file. Here is what my main entry file looks like:

import MyRouteComponent from "./my-route-component";

ReactDOM.render(
  <Router>
    <Route path="/" component={MyRouteComponent} />
    ...
  </Router>
  document.body
);

Maybe the entry file should be even simpler? Like:

import MyRouter from "./my-router";

ReactDOM.render(
  <MyRouter />,
  document.body
);

Would that work?

@gaearon
Copy link
Owner

gaearon commented Apr 9, 2016

Please provide a project reproducing the problem.

@gaearon
Copy link
Owner

gaearon commented Apr 9, 2016

Along with exact instructions to reproduce it

@gaearon
Copy link
Owner

gaearon commented Apr 18, 2016

Closing as there’s not enough information, and anyway a big change is coming: gaearon/react-hot-boilerplate#61

@gaearon gaearon closed this as completed Apr 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants