Skip to content

Add a static .prefetch() method to async! wrapper#604

Merged
reznord merged 1 commit intomasterfrom
async-component-prefetch
Aug 8, 2018
Merged

Add a static .prefetch() method to async! wrapper#604
reznord merged 1 commit intomasterfrom
async-component-prefetch

Conversation

@developit
Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Introduces a new static .prefetch() method on AsyncComponent (the wrapper component returned by async! imports:

import Foo from 'async!./foo';

// Perhaps we know for sure we'll need Foo soon:
Foo.prefetch();

// later on, this render can then happen synchronously:
render(<Foo />);

This can be useful for loading related routes.

Did you add tests for your changes?

Nope.

Summary

It is sometimes useful to prefetch lazy chunks when you know they'll be needed soon. This is a pretty tiny and unobtrusive way to do it.

Does this PR introduce a breaking change?

Nope.

import Foo from 'async!./foo'

Foo.prefetch()  // we know we'll want it.

render(<Foo />)
@developit developit requested review from lukeed and prateekbh July 27, 2018 15:12
@lukeed
Copy link
Copy Markdown
Member

lukeed commented Jul 27, 2018

You almost exceeded your byte limit on this one.

@lukeed
Copy link
Copy Markdown
Member

lukeed commented Jul 27, 2018

Our tests be like

@developit
Copy link
Copy Markdown
Member Author

Test errors look like a cert generation issue.

@reznord
Copy link
Copy Markdown
Member

reznord commented Aug 6, 2018

Yup, can we fix the tests cert issue as well? (For making travis happy)

@reznord reznord merged commit 63e2dfe into master Aug 8, 2018
@lukeed lukeed deleted the async-component-prefetch branch October 3, 2018 22:57
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.

4 participants