Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit 8b8bb9c

Browse files
committed
Patch for GitHub issue 5.
1 parent bba0c8a commit 8b8bb9c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/imageCacheHoc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ export default function imageCacheHoc(Image, options = {}) {
159159
async componentWillUnmount() {
160160

161161
// Cancel pending setState() actions.
162-
this.cancelLocalFilePathRequest();
162+
// NOTE: must check this.cancelLocalFilePathRequest is set to avoid edge case where component is mounted then immediately unmounted before componentDidMount() fires.
163+
if (this.cancelLocalFilePathRequest) {
164+
this.cancelLocalFilePathRequest();
165+
}
166+
163167

164168
// Remove component cache lock on associated image file on component teardown.
165169
let fileName = await this.fileSystem.getFileNameFromUrl(traverse(this.props).get(['source', 'uri']));

0 commit comments

Comments
 (0)