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 49fc6ff commit 2e763fb
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 @@ -73,10 +73,15 @@ const OSD: React.FC<OSDProps> = ({
openSeadragon?.addTiledImage({
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 2e763fb

Please sign in to comment.