Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Is there a similar way to use v4 like v3? #953

Closed
yangmingshan opened this issue Apr 30, 2018 · 5 comments
Closed

[Question] Is there a similar way to use v4 like v3? #953

yangmingshan opened this issue Apr 30, 2018 · 5 comments

Comments

@yangmingshan
Copy link

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?

@theKashey
Copy link
Collaborator

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.

@yangmingshan
Copy link
Author

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.

@theKashey
Copy link
Collaborator

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

@sibelius
Copy link

does this work with https://github.com/jamiebuilds/react-loadable?

@theKashey
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants