cache promise on load/preload (#830)

This commit is contained in:
Matej Vobornik 2021-12-12 05:24:42 +01:00 committed by GitHub
parent 9ff66939ee
commit 33cb54dfbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}