Skip to content

Commit 6677fde

Browse files
committed
Rename state condition to isMounted
1 parent 76313a3 commit 6677fde

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ui/widgets/EmbeddedDisplay/useOpiFile.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ export function useOpiFile(file: File): WidgetDescription {
7878
const [contents, setContents] = useState<WidgetDescription>(EMPTY_WIDGET);
7979

8080
useEffect(() => {
81-
let isMounted = false;
81+
let isMounted = true;
8282
const fetchData = async (): Promise<void> => {
8383
if (fetchPromises.hasOwnProperty(file.path)) {
8484
// This resource has been requested; once the cached
8585
// promise has been resolved the fileCache should be
8686
// populated.
8787
await fetchPromises[file.path];
88-
if (!isMounted) {
88+
if (isMounted) {
8989
setContents(fileCache[file.path]);
9090
}
9191
} else {
@@ -95,7 +95,7 @@ export function useOpiFile(file: File): WidgetDescription {
9595
const contents = await fetchPromise;
9696
// Populate the file cache.
9797
fileCache[file.path] = contents;
98-
if (!isMounted) {
98+
if (isMounted) {
9999
setContents(contents);
100100
}
101101
}
@@ -104,7 +104,7 @@ export function useOpiFile(file: File): WidgetDescription {
104104

105105
// Tidy up in case component is unmounted
106106
return () => {
107-
isMounted = true;
107+
isMounted = false;
108108
};
109109
}, [file.path, file.defaultProtocol, fileExt]);
110110

0 commit comments

Comments
 (0)