Repository navigation
Rewrite for 4.0 - #46
Merged
Merged
Conversation
Owner
Author
|
Added Loadable.Map({
loader: {
Component: () => import('./my-component'),
translations: () => fetch('./foo-translations.json').then(res => res.json()),
},
render(loaded, props) {
let Component = loaded.Component.default;
let translations = loaded.translations;
return <Component {...props} translations={translations}/>;
}
}); |
odensc
pushed a commit
to odensc/DefinitelyTyped
that referenced
this pull request
Jun 17, 2017
odensc
pushed a commit
to odensc/DefinitelyTyped
that referenced
this pull request
Jun 17, 2017
odensc
pushed a commit
to odensc/DefinitelyTyped
that referenced
this pull request
Jun 17, 2017
7 tasks done
odensc
pushed a commit
to odensc/DefinitelyTyped
that referenced
this pull request
Jun 17, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes:
opts.LoadingComponent→opts.loadingopts.resolveModulewithopts.renderfor more controlopts.timeoutto go along withopts.delayopts.delaycan be disabled by setting it tofalseornullopts.serverSideRequirePath(useimport-inspector)opts.webpackRequireWeakId(useimport-inspector)Loadable.flushServerSideRequirePaths(useimport-inspector)Loadable.flushwebpackRequireWeakIds(useimport-inspector)import-inspectorbabel-plugin-import-inspectorLoadable.Mapfor loading multiple resources in parallelopts.renderThis replaces
opts.resolveModuleto give more control over the actual rendering of the component.opts.timeoutVue added this, I liked it so I stole it.
import-inspector
Rather than having a custom API tied to React Loadable for dealing with making
import()compatible with synchronous workflows like server-side rendering and first render using Webpack, I've integrated React Loadable with a new library calledimport-inspectorwhich looks like this:You can automate all of this using:
babel-plugin-import-inspector
Since integrating with
import-inspectorthere's little reason to support a half-baked half-working Babel plugin specific to React Loadable.Instead, babel-plugin-import-inspector can automatically add everything you need:
Install
.babelrc:
{ "plugins": [ ["import-inspector", { "serverSideRequirePath": true, "webpackRequireWeakId": true }] ] }Input:
Output:
flushServerSideRequirePathsandflushwebpackRequireWeakIdsThis functionality is no longer necessary when using
import-inspector.Instead you can do this:
Loadable.MapIf you want to load multiple resources in parallel and stitch them together in the
render()method you can now do that withLoadable.Map.