Skip to content

Commit

Permalink
fix: crash on multiple SWR instances (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 authored Sep 10, 2023
1 parent eab606b commit 75f2d43
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/swr-devtools/src/createSWRDevTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ export const createSWRDevtools = () => {
});
}

const swrdevtools: Middleware = (useSWRNext) => (key, fn, config) => {
// use the same React instance with the application
const { useLayoutEffect, useEffect, useRef } =
typeof window !== "undefined" &&
// @ts-expect-error
typeof window.__SWR_DEVTOOLS_REACT__ !== "undefined"
? // @ts-expect-error
window.__SWR_DEVTOOLS_REACT__
: dummyHooks;
// use the same React instance with the application
const { useLayoutEffect, useEffect, useRef } =
typeof window !== "undefined" &&
// @ts-expect-error
typeof window.__SWR_DEVTOOLS_REACT__ !== "undefined"
? // @ts-expect-error
window.__SWR_DEVTOOLS_REACT__
: dummyHooks;

const swrdevtools: Middleware = (useSWRNext) => (key, fn, config) => {
useLayoutEffect(() => {
window.postMessage({ type: "initialized" }, "*");
}, []);
Expand Down

1 comment on commit 75f2d43

@vercel
Copy link

@vercel vercel bot commented on 75f2d43 Sep 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

swr-devtools – ./

swr-devtools-koba04.vercel.app
swr-devtools-git-main-koba04.vercel.app
swr-devtools.vercel.app

Please sign in to comment.