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

Return promise from component.preload() #313

Closed
wants to merge 2 commits into from
Closed

Return promise from component.preload() #313

wants to merge 2 commits into from

Conversation

parties
Copy link

@parties parties commented Apr 18, 2019

Preface: I'm not sure if this is the "correct" solution to my problem (maybe I missed something in the documentation) but this was the only way I could find to hook into the process that actually loads the component.

Summary

The problem I've been experiencing is that I needed to be able to call Component.preload() to load a component, but also wait for preload() to complete before rendering the route.

(We're stuck using react-router 3.x for the time being...)

This PR solves our problem by simply returning ctor. requireAsync(props) from the preload() function, as requireAsync already returns a promise that resolves once the component is loaded.

Test plan

Where are the tests for loadable/component? Am I missing something?

@parties
Copy link
Author

parties commented Apr 19, 2019

@parties parties closed this Apr 19, 2019
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.

1 participant