Skip to content

Commit

Permalink
feat: add load method that returns a Promise (gregberge#329)
Browse files Browse the repository at this point in the history
See gregberge#226 for context
  • Loading branch information
gregberge authored May 9, 2019
1 parent 90ab8ba commit e2b8d39
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/createLoadable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
return ctor.requireAsync(props)
}

return Loadable
}

Expand Down

0 comments on commit e2b8d39

Please sign in to comment.