Skip to content

Commit 75f2d43

Browse files
authored
fix: crash on multiple SWR instances (#126)
1 parent eab606b commit 75f2d43

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/swr-devtools/src/createSWRDevTools.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,16 @@ export const createSWRDevtools = () => {
113113
});
114114
}
115115

116-
const swrdevtools: Middleware = (useSWRNext) => (key, fn, config) => {
117-
// use the same React instance with the application
118-
const { useLayoutEffect, useEffect, useRef } =
119-
typeof window !== "undefined" &&
120-
// @ts-expect-error
121-
typeof window.__SWR_DEVTOOLS_REACT__ !== "undefined"
122-
? // @ts-expect-error
123-
window.__SWR_DEVTOOLS_REACT__
124-
: dummyHooks;
116+
// use the same React instance with the application
117+
const { useLayoutEffect, useEffect, useRef } =
118+
typeof window !== "undefined" &&
119+
// @ts-expect-error
120+
typeof window.__SWR_DEVTOOLS_REACT__ !== "undefined"
121+
? // @ts-expect-error
122+
window.__SWR_DEVTOOLS_REACT__
123+
: dummyHooks;
125124

125+
const swrdevtools: Middleware = (useSWRNext) => (key, fn, config) => {
126126
useLayoutEffect(() => {
127127
window.postMessage({ type: "initialized" }, "*");
128128
}, []);

0 commit comments

Comments
 (0)