Skip to content

Commit ed7b643

Browse files
authored
fix: send the panelshow event with SWRDevTools (#108)
1 parent 596e4c2 commit ed7b643

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/swr-devtools/src/SWRDevTools.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef } from "react";
1+
import React, { useEffect, useRef } from "react";
22
import { SWRConfig } from "swr";
33
import { EventEmitter, createSWRDevtools } from "./createSWRDevTools";
44

@@ -15,6 +15,9 @@ if (typeof window !== "undefined") {
1515

1616
export const SWRDevTools = ({ children }: { children: React.ReactNode }) => {
1717
const [swrdevtools, events] = useRef(createSWRDevtools()).current;
18+
useEffect(() => {
19+
window.postMessage({ type: "panelshow" });
20+
}, []);
1821
return (
1922
<SWRDevToolsContext.Provider value={{ events }}>
2023
<SWRConfig value={{ use: [swrdevtools] }}>{children}</SWRConfig>

0 commit comments

Comments
 (0)