React-hot-loader: [3.0] doesn't work with lazy modules

Created on 29 Dec 2016  路  3Comments  路  Source: gaearon/react-hot-loader

Here's an example: https://github.com/mqklin/hot-loader-lazy-modules-bug

import NotLazy from './NotLazy';

class App extends Component {
  state = {
    Lazy: () => null,
  };

  componentWillMount() {
    setTimeout(async () => {
      const Lazy = await import('./Lazy');
      this.setState({ Lazy: Lazy.default });
    }, 1500);
  }

  render() {
    const { Lazy } = this.state;
    return (
      <div>
        <NotLazy />
        <Lazy />
      </div>
    );
  }
}

Changes in Lazy component aren't applied.

Most helpful comment

Yeah dynamic imports might be a place where our Babel plugin/Webpack loader for 3.0 should add a module.hot.accept() call. We'll definitely visit this before the full 3.0 release.

All 3 comments

Seems to be a duplicate of #303, no?

Seems like it is. I think it's definitely not webpack's bug. import() (I use dynamic-import plugin) is converted into require.ensure, and this example works nicely with HMR v1.3.1. Please note, I don't use react-router, and use webpack v.1. My example is as small as possible.

Yeah dynamic imports might be a place where our Babel plugin/Webpack loader for 3.0 should add a module.hot.accept() call. We'll definitely visit this before the full 3.0 release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JamesIves picture JamesIves  路  4Comments

tiberiumaxim picture tiberiumaxim  路  4Comments

calvinchankf picture calvinchankf  路  3Comments

Anahkiasen picture Anahkiasen  路  5Comments

sandysaders picture sandysaders  路  4Comments