@sanity/ui 3.0.9 → 3.0.11-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import {useMemo, useRef, useSyncExternalStore} from 'react'
1
+ import {useMemo, useSyncExternalStore} from 'react'
2
2
 
3
3
  import {PortalContext} from './portalContext'
4
4
  import {PortalContextValue} from './types'
@@ -23,8 +23,7 @@ export interface PortalProviderProps {
23
23
  * @public
24
24
  */
25
25
  export function PortalProvider(props: PortalProviderProps): React.JSX.Element {
26
- const {boundaryElement, children, element, __unstable_elements: elementsProp} = props
27
- const elements = useUnique(elementsProp)
26
+ const {boundaryElement, children, element, __unstable_elements: elements} = props
28
27
  const fallbackElement = useSyncExternalStore(
29
28
  emptySubscribe,
30
29
  () => document.body,
@@ -46,34 +45,3 @@ export function PortalProvider(props: PortalProviderProps): React.JSX.Element {
46
45
  PortalProvider.displayName = 'PortalProvider'
47
46
 
48
47
  const emptySubscribe = () => () => {}
49
-
50
- /**
51
- * This is a React hook to make sure that a record identity is the same on every render. Uses strict
52
- * equality comparison (eg by identity), and only goes one level deep.
53
- */
54
- function useUnique<ValueType extends Comparable = Comparable>(value: ValueType): ValueType {
55
- const valueRef = useRef<ValueType>(value)
56
-
57
- if (!_isEqual(valueRef.current, value)) {
58
- valueRef.current = value
59
- }
60
-
61
- return valueRef.current
62
- }
63
-
64
- function _isEqual(objA: Comparable, objB: Comparable): boolean {
65
- if (!objA || !objB) {
66
- return objA === objB
67
- }
68
-
69
- const keysA = Object.keys(objA)
70
- const keysB = Object.keys(objB)
71
-
72
- if (keysA.length !== keysB.length) {
73
- return false
74
- }
75
-
76
- return keysA.every((key) => objA[key] === objB[key])
77
- }
78
-
79
- type Comparable = Record<string | number | symbol, unknown> | undefined | null