From f572f5f41ae8f34c91f4ee3227ee8db5b02eb6f8 Mon Sep 17 00:00:00 2001 From: Cody Olsen <81981+stipsan@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:06:33 +0100 Subject: [PATCH] fix: replace useMemo with useState (#8095) --- packages/sanity/src/core/form/store/useFormState.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/sanity/src/core/form/store/useFormState.ts b/packages/sanity/src/core/form/store/useFormState.ts index 591bab50dbb..3d1651fc6bf 100644 --- a/packages/sanity/src/core/form/store/useFormState.ts +++ b/packages/sanity/src/core/form/store/useFormState.ts @@ -57,40 +57,40 @@ export function useFormState< const [prepareReadOnlyState] = useState(() => createCallbackResolver({property: 'readOnly'})) const [prepareFormState] = useState(() => createPrepareFormState()) - const reconcileFieldGroupState = useMemo(() => { + const [reconcileFieldGroupState] = useState(() => { let last: StateTree | undefined return (state: StateTree | undefined) => { const result = immutableReconcile(last ?? null, state) last = result return result } - }, []) + }) const reconciledFieldGroupState = useMemo(() => { return reconcileFieldGroupState(fieldGroupState) }, [fieldGroupState, reconcileFieldGroupState]) - const reconcileCollapsedPaths = useMemo(() => { + const [reconcileCollapsedPaths] = useState(() => { let last: StateTree | undefined return (state: StateTree | undefined) => { const result = immutableReconcile(last ?? null, state) last = result return result } - }, []) + }) const reconciledCollapsedPaths = useMemo( () => reconcileCollapsedPaths(collapsedPaths), [collapsedPaths, reconcileCollapsedPaths], ) - const reconcileCollapsedFieldsets = useMemo(() => { + const [reconcileCollapsedFieldsets] = useState(() => { let last: StateTree | undefined return (state: StateTree | undefined) => { const result = immutableReconcile(last ?? null, state) last = result return result } - }, []) + }) const reconciledCollapsedFieldsets = useMemo( () => reconcileCollapsedFieldsets(collapsedFieldSets), [collapsedFieldSets, reconcileCollapsedFieldsets],