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

feat: add load method that returns a Promise #329

Merged
merged 1 commit into from
May 9, 2019
Merged

Conversation

gregberge
Copy link
Owner

@gregberge gregberge commented May 8, 2019

See #226 for context.

@gregberge
Copy link
Owner Author

@theKashey could you review it please?

@@ -195,6 +195,13 @@ function createLoadable({ resolve = identity, render, onLoad }) {
ctor.requireAsync(props)
}

Loadable.load = props => {
if (typeof window === 'undefined') {
throw new Error('`load` cannot be called server-side')
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is really has to be an error?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Another issue, for now I will let it like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was happy to see this PR but looking at the code I can not use it because of this limitation. I need as much client side as server.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I removed it 🤗

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you, that would be perfect with a method like isReady.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yep, but remember, if you need it, you are probably taking the wrong way to be Suspense ready. When Suspense will be released, you will not be able to wait for anything except in render.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know that Suspense does not allow it, but it's still useful information. In my case it allows me to display a progress bar when you have to load one or more chunks and not display it when they are already loaded.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ooff, how many chunks you have to load?

@theKashey
Copy link
Collaborator

😍, welcome to the club

@gregberge gregberge merged commit a10a9d5 into master May 9, 2019
@gregberge gregberge deleted the load-method branch May 9, 2019 17:48
fivethreeo pushed a commit to fivethreeo/loadable-components that referenced this pull request Nov 16, 2022
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.

3 participants