| 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) { |
no test coverage detected