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

doc: more clear statement about code splitting #963

Merged
merged 1 commit into from
May 7, 2018

Conversation

theKashey
Copy link
Collaborator

Related to #947
A bit more clear statement about code splitting..

@theKashey theKashey requested a review from gregberge May 3, 2018 01:12
@codecov-io
Copy link

codecov-io commented May 3, 2018

Codecov Report

Merging #963 into master will decrease coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #963      +/-   ##
==========================================
- Coverage   88.42%   88.33%   -0.09%     
==========================================
  Files          30       30              
  Lines         674      686      +12     
  Branches      156      163       +7     
==========================================
+ Hits          596      606      +10     
- Misses         64       66       +2     
  Partials       14       14
Impacted Files Coverage Δ
src/proxy/inject.js 77.27% <0%> (+1.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3e1208...ac53309. Read the comment docs.

Copy link
Collaborator

@gregberge gregberge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t want to promote a library which do not accept any GitHub issues.

@theKashey theKashey force-pushed the impove-async-loader-readme branch from a8a05aa to ac53309 Compare May 4, 2018 03:07

// Hello.js
import { hot } from 'react-hot-loader'
const Hello = () => 'Hello'
export default hot(module)(Hello) // <-- the only change to do
export default hot(module)(Hello) // <-- module will reload itself
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use loadable-components or react-imported-component. They provide the best support for RHL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are in a section about "friendly" loaders, and dont require any workaround example, as long just works.
We could swap sections, displaying an easy path first.

@@ -203,25 +203,36 @@ Using React Hot Loader with React Native can cause unexpected issues (see #824)

### Code Splitting

Most of modern React component-loader libraries ([loadable-components](https://github.com/smooth-code/loadable-components/),
[react-loadable](https://github.com/thejameskyle/react-loadable)...) are compatible with React Hot Loader.
Most of modern React component-loader libraries are not "100%" compatible with React-Hot-Loader, as long
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should discourage using react-loadable.

@gregberge
Copy link
Collaborator

I made some test on Loadable Components. I don't know what has changed but I no longer need to reload everything. It works out of the box without adding any code. Could be the same for React Loadable.

@theKashey
Copy link
Collaborator Author

You know, it sounds like a bug. Ok a huge change inside webpack.
It could only work is something triggered “register”.
Can you share that example?

@gregberge
Copy link
Collaborator

Example from this PR. Let's make it clear before rewriting this README section.

@theKashey
Copy link
Collaborator Author

@neoziro - so everything is due to autoload inside the constructor. Look like the condition should be a bit different, - preload only NOT for browser, to emulate componentWillMount on server-side.
In imported-component I am using detect-node for it. Fix and test this moment just last weekends, so I am pretty sure you shall do the same.

As result - the state of code splitting is unchanged. You still have somehow trigger reimport, and it will not work without it.

@gregberge
Copy link
Collaborator

@theKashey the behaviour that I want is loading in component but only server-side https://github.com/smooth-code/loadable-components/blob/master/src/loadable.js#L58. So I think doing it in constructor makes it compatible with HMR, so nice!

Yes the state of Code Splitting stay unchanged. Loadable Components and Imported Components work both out of the box.

@theKashey
Copy link
Collaborator Author

But typeof window !== 'undefined' is a browser, not server side.
Anyway, this one is good to merge.

@theKashey theKashey merged commit b22f37e into master May 7, 2018
@gregberge gregberge deleted the impove-async-loader-readme branch July 11, 2018 15:42
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

Successfully merging this pull request may close these issues.

None yet

3 participants