geowarin / boot-react

A starter application with spring boot and react

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hot reload not working for stateless components

pulse00 opened this issue · comments

Thanks for this repo, it helped a lot getting started with setting up spring and react!

Here's a question though: When running the frontend app using npm start, hot module replacement does not work when editing UI components:

process-update.js:59 [HMR] The following modules couldn't be hot updated: (Full reload needed)
 - ./src/ui/Component.js

Is this a known issue in this starter app?

Yes, unfortunately, stateless functional components are not yet supported by the react transform plugin...
The workaround is to create good old components extending React.Component

Change this:

export const MyComponent = (props) => {
...
}

to this:

export class MyComponent extends React.Component {

  render() {
...
  }
}

See:
gaearon/babel-plugin-react-transform#57

This is unfortunate since functional component are really awesome

I see, thanks for pointing to this issue.

commented

React Hot Loader 3 supports functional components without destroying the state.
It supersedes both React Hot Loader and React Transform, and is built on lessons learned from both.
Check it out: gaearon/react-hot-boilerplate#61