Skip to content

Commit

Permalink
cache promise on load/preload (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
macko911 committed Dec 12, 2021
1 parent 9ff6693 commit 33cb54d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/component/src/createLoadable.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,13 @@ function createLoadable({

// In future, preload could use `<link rel="preload">`
Loadable.preload = props => {
ctor.requireAsync(props)
cache[getCacheKey()] = ctor.requireAsync(props);
}

Loadable.load = props => ctor.requireAsync(props)
Loadable.load = props => {
cache[getCacheKey()] = ctor.requireAsync(props);
return cache[getCacheKey()];
}

return Loadable
}
Expand Down

0 comments on commit 33cb54d

Please sign in to comment.