socketio-zustand/frontend/src/app/provide.tsx

28 lines
696 B
TypeScript
Raw Normal View History

2023-07-14 15:38:27 +08:00
"use client";
import { MantineProvider } from "@mantine/core";
import RootStyleRegistry from "./emotion";
import { useEffect } from "react";
import useSocketStore from "@/store/socket";
type Prop = {
children: React.ReactNode;
};
export function AppProvider({ children }: Prop) {
const [disconnect] = useSocketStore(({ disconnect }) => [disconnect]);
useEffect(() => {
return () => {
console.log("disconnect");
disconnect();
};
}, []);
return (
<RootStyleRegistry>
<MantineProvider withGlobalStyles withNormalizeCSS>
{children}
</MantineProvider>
</RootStyleRegistry>
);
}