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.

Only top-level component hot reloads

See original GitHub issue

ETA: This issue actually does involve React Router, after all. Please see my comment further down the thread.

Previously:

I’m using 3.0.0-beta.1.

I originally thought the problem was with React Router but I’m updating the description to reflect what my problem actually is. React Router is fine.

Hot module reloading works for my root component and for any lower level components defined within the same module. However, hot module loading doesn’t seem to propagate down the import tree. Lower level components defined in separate files end up triggering the warning message, The following modules couldn't be hot updated: (They would need a full reload!).

Not sure what I’m doing wrong. Here’s how I’m telling webpack to re-render.

if (module.hot) {
  module.hot.accept('./root', () => {
    const NextRoot = require('./root').default;
    render(
      <AppContainer>
        <NextRoot {...{ store, history, onUpdate, routes }} />
      </AppContainer>,
      document.getElementById('app')
    );
  });
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:24 (8 by maintainers)

github_iconTop GitHub Comments

13reactions
gaearoncommented, May 3, 2016

Sorry, copy-pasting and setting up a project is really tedious to validate bug reports 😄 Can you please provide this on GitHub?

7reactions
davidlormorcommented, Jun 3, 2016

@benwiley4000 yes, whenever I switch the Route’s component from a stateless function to a class-based component the hot reload works, but when I switch it back to a stateless functional component the hot reload fails. (Tried across several routes/components)…it may have nothing to do with the Router, but rather something about stateless components, perhaps…like I mentioned I haven’t dived too deep into this issue, just sharing my observations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started · React Hot Loader - Dan gaearon
Note: react-hot-loader/webpack only works on exported components, whereas react-hot-loader/babel picks up all top-level variables in your files.
Read more >
Hot Reloading in React - Medium
React Hot Loader was my first popular open source project and, to my knowledge, the first tool that allowed you to edit React...
Read more >
Set up React Hot Loader in 10 minutes - LogRocket Blog
A hot reload to an app will only refresh the files that were ... again and wrap the app's top-level component inside of...
Read more >
Component not reloaded with react hot loader - Stack Overflow
I should've specified in my answer that two instances of webpack-dev-server were running before and now there's only one. You should be all...
Read more >
How to Hot-Load React Component in 7 days. Part 2(React)
Step 1 — React Hot Loader ... So, just after configuring HMR you have to add one new dependency to your project to...
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