diff --git a/packages/sanity/src/structure/panes/documentList/PaneContainer.tsx b/packages/sanity/src/structure/panes/documentList/PaneContainer.tsx index 92d18add010..1c3091bfdd2 100644 --- a/packages/sanity/src/structure/panes/documentList/PaneContainer.tsx +++ b/packages/sanity/src/structure/panes/documentList/PaneContainer.tsx @@ -1,6 +1,6 @@ import {Card, Code} from '@sanity/ui' import {isEqual} from 'lodash' -import {memo, useMemo, useRef} from 'react' +import {memo, useMemo, useState} from 'react' import { EMPTY_ARRAY, type GeneralDocumentListLayoutKey, @@ -49,11 +49,12 @@ const addSelectedStateToMenuItems = (options: { } export function useShallowUnique(value: ValueType): ValueType { - const valueRef = useRef(value) - if (!shallowEquals(valueRef.current, value)) { - valueRef.current = value + const [current, setCurrent] = useState(value) + if (!shallowEquals(current, value)) { + setCurrent(value) + return value } - return valueRef.current + return current } /**