ctrlplusb / react-universally

A starter kit for universal react applications.
MIT License
1.7k stars 244 forks source link

HMR not working properly on non-functional components #522

Closed howardya closed 6 years ago

howardya commented 6 years ago

To reproduce,

git clone yarn yarn develop

then change the following in the file shared/components/DemoApp/AsyncHomeRoute/HomeRoute.js

function HomeRoute() {
  return (
    <div>
      <Helmet>
        <title>Home</title>
      </Helmet>

      <h2>{config('welcomeMessage')}</h2>

      <p>
        This starter kit contains all the build tooling and configuration you
        need to kick off your next universal React project, whilst containing a
        minimal project set up allowing you to make your own architecture
        decisions (Redux/Mobx etc).
      </p>
    </div>
  );
}

to

class HomeRoute extends React.PureComponent { // eslint-disable-line
  render() {
    return (
      <div>
        <Helmet>
          <title>Home</title>
        </Helmet>

        <h2>{config('welcomeMessage')}</h2>

        <p>
          This starter kit contains all the build tooling and configuration you
          need to kick off your next universal React project, whilst containing a
          minimal project set up allowing you to make your own architecture
          decisions (Redux/Mobx etc).
        </p>
      </div>
    );
  }
}

The HMR will not work properly. Specifically, when we change the text, the browser will only reload for the second time I save.

Is this known issue?

ctrlplusb commented 6 years ago

Can you try use Component rather than PureComponent for interests sake?