react-webpack-generators / generator-react-webpack

Yeoman generator for ReactJS and Webpack
http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/
MIT License
2.88k stars 355 forks source link

React 15.4 breaking changes #302

Closed stylesuxx closed 7 years ago

stylesuxx commented 7 years ago

I got a report here and found some SO discussion.

The newest version of react seems to break the gen.

Temp fix is to use 15.3.0 or older:

npm install react@15.3.0

Seems to be related to react-hot-loader. Upgrading to react-hot-loader v3 should fix the problem, good that it is in beta -_-

sthzg commented 7 years ago

Thanks for reporting. Also a bit of context on Github https://github.com/gaearon/react-hot-loader/issues/417.

As the author of react-hot-loader states here that the stable 1.x hasn't received updates in a while and he considers 3.x to be more stable, do you have any objections to updating gen and template (both v3 and v4) to react hot loader v3?

I've setup RHL3 a few times in the past weeks, so I think it shouldn't take much time to get a PR ready for review. Otherwise this seems like a proper workaround: https://github.com/gaearon/react-hot-loader/issues/417#issuecomment-261548082

/cc @weblogixx

stylesuxx commented 7 years ago

I am all for this changes - I am depending on your version 4, so an update would benefit me a lot - getting quite the issues lately. Let me know how I can help.

phellipeandrade commented 7 years ago

Temp Fix using react 15.4.0

1. Remove react-hot from loaders in cfg/dev.js line 32

// Add needed loaders to the defaults here
config.module.loaders.push({
  test: /\.(js|jsx)$/,
  loader: 'babel-loader',
  include: [].concat(
    config.additionalPaths,
    [ path.join(__dirname, '/../src') ]
  )
});

2. insert this section in index.js

// Render the main component into the dom
ReactDOM.render(<App />, document.getElementById('app'));

if (module.hot) {
  module.hot.accept('./components/Main', () => {
     const NextApp = require('./components/Main').default;
    ReactDOM.render(
         <NextApp />, document.getElementById('app'));
  });
}
weblogixx commented 7 years ago

Hi,

I am currently migrating some projects to react-hot-loader@3, if it seems stable enough, I will update the template with it (V3 and V4)

sthzg commented 7 years ago

FYI: I have included the workaround (webpack alias to the new ReactMount location) into the v1.7.3 release of the template repo. This fixes installing/running the stable 3.x generator. Once the long-term solution discussed here and in @stylesuxx 's PR we could remove that alias again, but I feel that it was important to provide users of the 3.x line with a quick solution.

More info

sthzg commented 7 years ago

Fixed now as follows:

Thanks for your patience and contributions.