MCPcopy Index your code
hub / github.com/gregberge/loadable-components / cachedLoad

Function cachedLoad

packages/component/src/createLoadable.js:91–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89 }
90
91 const cachedLoad = props => {
92 const cacheKey = getCacheKey(props)
93 let promise = cache[cacheKey]
94
95 if (!promise || promise.status === STATUS_REJECTED) {
96 promise = ctor.requireAsync(props)
97 promise.status = STATUS_PENDING
98
99 cache[cacheKey] = promise
100
101 promise.then(
102 () => {
103 promise.status = STATUS_RESOLVED
104 },
105 error => {
106 console.error(
107 'loadable-components: failed to asynchronously load component',
108 {
109 fileName: ctor.resolve(props),
110 chunkName: ctor.chunkName(props),
111 error: error ? error.message : error,
112 },
113 )
114 promise.status = STATUS_REJECTED
115 },
116 )
117 }
118
119 return promise
120 }
121
122 class InnerLoadable extends React.Component {
123 static getDerivedStateFromProps(props, state) {

Callers 2

resolveAsyncMethod · 0.85
loadableFunction · 0.85

Calls 1

getCacheKeyFunction · 0.85

Tested by

no test coverage detected