markerikson / marks-dev-blog-comments

Comments for my blog
4 stars 0 forks source link

Blogged Answers: Webpack HMR vs React-Hot-Loader #20

Open markerikson opened 3 years ago

markerikson commented 3 years ago

Original author: Andy Edwards
Original date: 2018-09-04T23:54:31Z

It's also worth mentioning that there's an easy alternative to `react-hot-loader` that's way less invasive: using a `module.hot.accept` function to reload the root component of the app when anything changes.
After dealing with a series of cases `react-hot-loader` was unable to reload, as well as very subtle bugs in its babel plugin, I decided it would be a lot less trouble to rely on remounting the root component.

markerikson commented 3 years ago

Original date: 2018-09-05T00:04:53Z

That's exactly what I mean by "plain HMR" , as shown in the post I linked :)

markerikson commented 3 years ago

Original author: Andy Edwards
Original date: 2018-09-05T01:11:04Z

Ah whoops, sorry...I skimmed :/

markerikson commented 3 years ago

Original author: Alex Leung @Alleung234
Original date: 2018-11-17T11:07:17Z

I like this approach. Keep all client-side application state outside of components in MobX or Redux and apply vanilla HMR to that, then RHL is unnecessary and you can just reload from the root component.

On another note, I wonder if the new React hooks API will be used as the basis to a new approach to React hot module replacement that is orthogonal to the original RHL effort.

markerikson commented 3 years ago

Original author: 小冶 @fatfatson
Original date: 2019-06-15T03:50:54Z

very good explanation ~
I'm using `plain hmr` always and find it completely satisfy need, so that don't understand why `react-hot-loader` borns.
you make me clear