From 29043f63b6f3af277b68cf8f685460068c946fa6 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 5 Mar 2024 22:26:52 +0800 Subject: [PATCH] chore: fix set state --- .../web/src/components/CreateCollectionDrawer.tsx | 14 +++++++------- .../web/src/components/CreateShortcutDrawer.tsx | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/frontend/web/src/components/CreateCollectionDrawer.tsx b/frontend/web/src/components/CreateCollectionDrawer.tsx index c7a6fc0..18fc6e2 100644 --- a/frontend/web/src/components/CreateCollectionDrawer.tsx +++ b/frontend/web/src/components/CreateCollectionDrawer.tsx @@ -51,6 +51,13 @@ const CreateCollectionDrawer: React.FC = (props: Props) => { }) .filter((shortcut) => !selectedShortcuts.find((selectedShortcut) => selectedShortcut.id === shortcut.id)); + const setPartialState = (partialState: Partial) => { + setState({ + ...state, + ...partialState, + }); + }; + useEffect(() => { if (workspaceStore.setting.defaultVisibility !== Visibility.VISIBILITY_UNSPECIFIED) { setPartialState({ @@ -87,13 +94,6 @@ const CreateCollectionDrawer: React.FC = (props: Props) => { return null; } - const setPartialState = (partialState: Partial) => { - setState({ - ...state, - ...partialState, - }); - }; - const handleNameInputChange = (e: React.ChangeEvent) => { setPartialState({ collectionCreate: Object.assign(state.collectionCreate, { diff --git a/frontend/web/src/components/CreateShortcutDrawer.tsx b/frontend/web/src/components/CreateShortcutDrawer.tsx index e716f63..cd30cef 100644 --- a/frontend/web/src/components/CreateShortcutDrawer.tsx +++ b/frontend/web/src/components/CreateShortcutDrawer.tsx @@ -59,6 +59,13 @@ const CreateShortcutDrawer: React.FC = (props: Props) => { const loadingState = useLoading(!isCreating); const requestState = useLoading(false); + const setPartialState = (partialState: Partial) => { + setState({ + ...state, + ...partialState, + }); + }; + useEffect(() => { if (workspaceStore.setting.defaultVisibility !== Visibility.VISIBILITY_UNSPECIFIED) { setPartialState({ @@ -94,13 +101,6 @@ const CreateShortcutDrawer: React.FC = (props: Props) => { return null; } - const setPartialState = (partialState: Partial) => { - setState({ - ...state, - ...partialState, - }); - }; - const handleNameInputChange = (e: React.ChangeEvent) => { setPartialState({ shortcutCreate: Object.assign(state.shortcutCreate, {