React-hot-loader: [Question] Is there a similar way to use v4 like v3?

Created on 30 Apr 2018  路  5Comments  路  Source: gaearon/react-hot-loader

The hot helper provided by v4 is great. But our application have over 50 pages, each page is loaded on demand. So if I use hot helper, I have to rewrite every page's export. And if the page need connect to redux, the export will be like this:

export default hot(module)(connect(mapStateToProps)(MyComponent));

It's maybe too long and complicated.

So, is there a similar way to use v4 like v3?

All 5 comments

If you were able to handle your project with v3 - you should be able to do it with v4.
hot is just a AppContainer + module.hot setup - you can do everything by yourself.

Just beware -hot-loader could not "bypass" async-loader, react-loadable for example, as long they load chunks only onMount.
But there is more "RHL-friendly" loaders like loadable-components, or react-imported-component.

Our async-loader was written by myself, But I found the solution in react-imported-component.

Use hot wrap the root component, async-loader reload async component after root component updated. No need to wrap async component's export.

I'm not sure it's the right way, but it works. Thank you.

There is super simple RHL-frindly solution in loadable-components - it just always load a new component.

Unfortunately no. Everyone has to pick it's own way to detect HRM and the way to reload stuff then. React-loadable still could not choose, but we have ideas how to enable every loader to work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theKashey picture theKashey  路  3Comments

Anahkiasen picture Anahkiasen  路  5Comments

Opty1712 picture Opty1712  路  4Comments

zlk89 picture zlk89  路  3Comments

ghost picture ghost  路  3Comments