Skip to content

Commit

Permalink
fix crash if dispatch is not a function
Browse files Browse the repository at this point in the history
  • Loading branch information
wykhuh committed May 1, 2024
1 parent 3ad33f4 commit 67557cb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/Image/OSD/OSD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,15 @@ const OSD: React.FC<OSDProps> = ({
openSeadragon.addTiledImage({
tileSource: tileSource,
success: () => {
dispatch({
type: "updateOSDImageLoaded",
OSDImageLoaded: true,
});
// NOTE: need to check dispatch is a function, because when
// using dev server, dispatch sometimes is set to
// ViewerContext.defaultState object instead of a function
if (typeof dispatch === "function") {
dispatch({
type: "updateOSDImageLoaded",
OSDImageLoaded: true,
});
}
},
});
} catch (e) {
Expand Down

0 comments on commit 67557cb

Please sign in to comment.