From 0c633a561da68cdd6425c0c1466a460502c2bfc3 Mon Sep 17 00:00:00 2001 From: Slouchwind <2241051890@qq.com> Date: Sun, 16 Apr 2023 20:30:30 +0800 Subject: [PATCH] fix bug --- components/extraReact.ts | 2 +- components/window.tsx | 4 ++-- pages/chat.tsx | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/extraReact.ts b/components/extraReact.ts index 564b61d..f45999a 100644 --- a/components/extraReact.ts +++ b/components/extraReact.ts @@ -1,4 +1,4 @@ -export function useClassState( +export function getClassState( useState: [S, React.Dispatch>] ): [S, (newState: Partial) => void] { const setState = (newState: Partial) => useState[1]((preState) => ({ ...preState, ...newState })); diff --git a/components/window.tsx b/components/window.tsx index 9faca29..452bc49 100644 --- a/components/window.tsx +++ b/components/window.tsx @@ -1,6 +1,6 @@ import React from "react"; import Repeat from "./repeat"; -import { useClassState } from './extraReact'; +import { getClassState } from './extraReact'; import randomId from "./randomId"; interface WindowProps { @@ -96,7 +96,7 @@ export function AllWindows({ zIndex, allWindow }: { export function getWindowFun( useState: [AllWindow, React.Dispatch>] ) { - const [allWindow, setAllWindow] = useClassState(useState); + const [allWindow, setAllWindow] = getClassState(useState); function addNewWindow( window: Window, Component: WindowTypeComArg diff --git a/pages/chat.tsx b/pages/chat.tsx index 27402a9..24b90b1 100644 --- a/pages/chat.tsx +++ b/pages/chat.tsx @@ -15,7 +15,7 @@ import { getStudentInfo, getStudentsJson } from '@/components/students/infoStude import Window, { AllWindow, getWindowFun } from '@/components/window'; import Repeat from '@/components/repeat'; import { AllWindows } from '@/components/window'; -import { useClassState } from '@/components/extraReact'; +import { getClassState } from '@/components/extraReact'; interface ContentProps { id: number, @@ -68,7 +68,7 @@ interface TextAlertArg { } export default function Info() { - const [state, setState] = useClassState(useState({ + const [state, setState] = getClassState(useState({ student: 0, studentsList: [10000, 10002], studentsJson: { data: {} },