-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Conversation
See #226 for context
@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') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it 🤗
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
😍, welcome to the club |
See gregberge#226 for context
See #226 for context.