React-hot-loader: in the future, can we don't need to change any code to use react-hot-loader?

Created on 9 Jan 2018  ·  2Comments  ·  Source: gaearon/react-hot-loader

After I use v4, I feel very good because of change less code than v3!

So I have a fantasy idea, that is, in the future, can we don't need to change any code to use react-hot-loader?

PS: I found the latest version of vue-loader has already achieved it.

Thanks a lot!

Most helpful comment

The steps to make it:

  1. Auto-patch react-dom render method to auto inject the first part of RHL. As we do with React.createElement.
  2. Detect files with __only__ React components as exports, and autowrap them with hot

This is doable for .vue, .tsx or .jsx, as long it is possible to understand - HERE IS THE COMPONENT, you can reload in isolation.

But lots of people use plain js to write the code. React-hot-loader v1 does contain this sort of automagic, but it was build for the older versions React, when Stateless components does not exists.
There is no (stable) way to distinguish function stateless component and a function :( So there is no (stable) way to setup HMR for random set of files.

It is still possible to detect the places where HRM could be safely injected, (for lots of use cases one point ("App") is enough) just by analyzing module dependencies, and should be researched.

All 2 comments

The steps to make it:

  1. Auto-patch react-dom render method to auto inject the first part of RHL. As we do with React.createElement.
  2. Detect files with __only__ React components as exports, and autowrap them with hot

This is doable for .vue, .tsx or .jsx, as long it is possible to understand - HERE IS THE COMPONENT, you can reload in isolation.

But lots of people use plain js to write the code. React-hot-loader v1 does contain this sort of automagic, but it was build for the older versions React, when Stateless components does not exists.
There is no (stable) way to distinguish function stateless component and a function :( So there is no (stable) way to setup HMR for random set of files.

It is still possible to detect the places where HRM could be safely injected, (for lots of use cases one point ("App") is enough) just by analyzing module dependencies, and should be researched.

Thanks for your reply! I will try to research it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

esturcke picture esturcke  ·  3Comments

tiberiumaxim picture tiberiumaxim  ·  4Comments

rockchalkwushock picture rockchalkwushock  ·  3Comments

mattkrick picture mattkrick  ·  3Comments

theKashey picture theKashey  ·  4Comments