Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(performance): improve useArrayProp memoization #1470

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ module.exports = {
],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'boundaries/element-types': [
'error',
Expand Down Expand Up @@ -76,17 +74,6 @@ module.exports = {
],
'no-console': 'error',
'no-warning-comments': ['warn', {location: 'start', terms: ['todo', '@todo', 'fixme']}],
'padding-line-between-statements': [
'warn',
{blankLine: 'always', prev: '*', next: 'block'},
{blankLine: 'always', prev: '*', next: 'block-like'},
{blankLine: 'always', prev: 'const', next: 'expression'},
{blankLine: 'always', prev: 'let', next: 'expression'},
{blankLine: 'always', prev: 'var', next: 'expression'},
{blankLine: 'always', prev: 'block', next: '*'},
{blankLine: 'always', prev: 'block-like', next: '*'},
{blankLine: 'always', prev: '*', next: 'return'},
],
'react/prop-types': 'off',
'react-hooks/exhaustive-deps': 'error', // Checks effect dependencies
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- run: pnpm install
- name: Register Problem Matcher for ESLint that handles -f compact and shows warnings and errors inline on PRs
run: echo "::add-matcher::.github/eslint-compact.json"
- run: "pnpm lint -f compact --rule 'no-warning-comments: [off]' --max-warnings 33"
- run: "pnpm lint -f compact --rule 'no-warning-comments: [off]' --max-warnings 27"

test:
needs: [build]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sanity/ui",
"version": "2.8.23",
"version": "2.8.24-canary.2",
"keywords": [
"sanity",
"ui",
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/autocomplete/autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
} from 'react'
import {EMPTY_ARRAY, EMPTY_RECORD} from '../../constants'
import {_hasFocus, _raf, focusFirstDescendant} from '../../helpers'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {
Box,
BoxProps,
Expand Down Expand Up @@ -97,7 +97,7 @@
const DEFAULT_FILTER_OPTION = (query: string, option: BaseAutocompleteOption) =>
option.value.toLowerCase().indexOf(query.toLowerCase()) > -1

const InnerAutocomplete = forwardRef(function InnerAutocomplete<

Check warning on line 100 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:638:24)

Check warning on line 100 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:635:8)

Check warning on line 100 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:642:8)

Check warning on line 100 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) (@:665:26)
Option extends BaseAutocompleteOption,
>(
props: AutocompleteProps<Option> &
Expand Down Expand Up @@ -632,14 +632,14 @@
const results = useMemo(() => {
if (renderPopover) {
return renderPopover(
{

Check warning on line 635 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
content,
hidden: !expanded,
inputElement: inputElementRef.current,

Check warning on line 638 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
onMouseEnter: handlePopoverMouseEnter,
onMouseLeave: handlePopoverMouseLeave,
},
resultsPopoverElementRef,

Check warning on line 642 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
)
}

Expand All @@ -662,7 +662,7 @@
portal
radius={radius}
ref={resultsPopoverElementRef}
referenceElement={inputElementRef.current}

Check warning on line 665 in src/core/components/autocomplete/autocomplete.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
{...popover}
/>
)
Expand Down
3 changes: 2 additions & 1 deletion src/core/components/breadcrumbs/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
useRef,
useState,
} from 'react'
import {useArrayProp, useClickOutsideEvent} from '../../hooks'
import {useClickOutsideEvent} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {Box, Popover, Stack, Text} from '../../primitives'
import {ExpandButton, Root} from './breadcrumbs.styles'

Expand All @@ -24,7 +25,7 @@
/**
* @beta
*/
export const Breadcrumbs = forwardRef(function Breadcrumbs(

Check warning on line 28 in src/core/components/breadcrumbs/breadcrumbs.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output. (@:43:19)

Check warning on line 28 in src/core/components/breadcrumbs/breadcrumbs.tsx

View workflow job for this annotation

GitHub Actions / ESLint

[ReactCompilerBailout] React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This dependency may be mutated later, which could cause the value to change unexpectedly (@:82:41)
props: BreadcrumbsProps & Omit<React.HTMLProps<HTMLOListElement>, 'as' | 'ref' | 'type'>,
ref: React.ForwardedRef<HTMLOListElement>,
) {
Expand Down
8 changes: 2 additions & 6 deletions src/core/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ import {
focusLastDescendant,
isHTMLElement,
} from '../../helpers'
import {
useArrayProp,
useClickOutsideEvent,
useGlobalKeyDown,
usePrefersReducedMotion,
} from '../../hooks'
import {useClickOutsideEvent, useGlobalKeyDown, usePrefersReducedMotion} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {Box, Button, Card, Container, Flex, Text} from '../../primitives'
import {ResponsivePaddingProps, ResponsiveWidthProps} from '../../primitives/types'
import {responsivePaddingStyle, ResponsivePaddingStyleProps} from '../../styles/internal'
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/hotkeys/hotkeys.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {Inline, KBD} from '../../primitives'
import {Radius} from '../../types'

Expand Down
2 changes: 1 addition & 1 deletion src/core/components/menu/menuGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ChevronRightIcon} from '@sanity/icons'
import {isValidElement, useCallback, useEffect, useState} from 'react'
import {isValidElementType} from 'react-is'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {Box, Flex, Popover, PopoverProps, Text} from '../../primitives'
import {Selectable} from '../../primitives/_selectable'
import {useRootTheme} from '../../theme'
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/menu/menuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
useState,
} from 'react'
import {isValidElementType} from 'react-is'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {Box, Flex, Text} from '../../primitives'
import {Selectable} from '../../primitives/_selectable'
import {ResponsivePaddingProps, ResponsiveRadiusProps} from '../../primitives/types'
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/skeleton/skeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {forwardRef, useEffect, useState} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {Box} from '../../primitives'
import {BoxProps, ResponsiveRadiusProps} from '../../primitives'
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/skeleton/textSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ThemeFontKey, getTheme_v2} from '@sanity/ui/theme'
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {ThemeProps, _responsive} from '../../styles'
import {Skeleton, SkeletonProps} from './skeleton'

Expand Down
2 changes: 1 addition & 1 deletion src/core/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './useArrayProp'
export * from './useArrayPropLegacy'
export * from './useClickOutside'
export * from './useClickOutsideEvent'
export * from './useCustomValidity'
Expand Down
14 changes: 8 additions & 6 deletions src/core/hooks/useArrayProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@ export type ArrayPropPrimitive = string | number | boolean | undefined | null
*/
export function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
val: T | T[] | undefined,
defaultVal?: T[],
): T[] {
const [[cachedVal, cachedHash], setCache] = useState<[T[], string]>(() => [
_getArrayProp(val, defaultVal),
JSON.stringify(val ?? defaultVal),
_getArrayProp(val),
JSON.stringify(val),
])
let result = cachedVal

const hash = JSON.stringify(val ?? defaultVal)
const hash = JSON.stringify(val)

if (hash !== cachedHash) {
const current = _getArrayProp(val)
// If the cached hash has changed, update the cache right away.
// Calling setState during render is fine in this case, and preferred over a useEffect loop
// https://19.react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
setCache([_getArrayProp(val, defaultVal), hash])
setCache([current, hash])
result = current
}

return cachedVal
return result
}
30 changes: 30 additions & 0 deletions src/core/hooks/useArrayPropLegacy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {useArrayProp as useArrayPropHook, type ArrayPropPrimitive} from './useArrayProp'

export type {ArrayPropPrimitive}

/**
* This API might change. DO NOT USE IN PRODUCTION.
* @beta
*/
export function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
val: T | T[] | undefined,
): T[]
/**
* This API might change. DO NOT USE IN PRODUCTION.
* @beta
* @deprecated - use `useArrayProp(value ?? defaultValue)` instead of `useArrayProp(value, defaultValue)`
*/
export function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
val: T | T[] | undefined,
defaultVal: T[],
): T[]
/**
* This API might change. DO NOT USE IN PRODUCTION.
* @beta
*/
export function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
val: T | T[] | undefined,
defaultVal?: T[],
): T[] {
return useArrayPropHook(val ?? defaultVal)
}
2 changes: 1 addition & 1 deletion src/core/primitives/avatar/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {ThemeColorAvatarColorKey} from '@sanity/ui/theme'
import {forwardRef, useCallback, useEffect, useId, useMemo, useState} from 'react'
import ReactIs from 'react-is'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {useTheme_v2} from '../../theme'
import {AvatarPosition, AvatarSize, AvatarStatus} from '../../types'
import {Label} from '../label'
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/avatar/avatarCounter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {getTheme_v2} from '@sanity/ui/theme'
import {forwardRef, useMemo} from 'react'
import {styled, css} from 'styled-components'
import {EMPTY_RECORD} from '../../constants'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {rem, _responsive, ThemeProps} from '../../styles'
import {AvatarSize} from '../../types'
import {Label} from '../label'
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/avatar/avatarStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {getTheme_v2} from '@sanity/ui/theme'
import {Children, cloneElement, forwardRef, isValidElement} from 'react'
import {styled, css} from 'styled-components'
import {EMPTY_RECORD} from '../../constants'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {rem, _responsive, ThemeProps} from '../../styles'
import {AvatarSize} from '../../types'
import {AvatarCounter} from './avatarCounter'
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/badge/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
import {BadgeMode, BadgeTone} from '../../types'
import {Box, BoxProps} from '../box'
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/box/box.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {
boxStyle,
flexItemStyle,
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {forwardRef, isValidElement, useMemo} from 'react'
import {isValidElementType} from 'react-is'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {ThemeProps} from '../../styles'
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
import {useTheme_v2} from '../../theme'
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {ThemeColorSchemeKey} from '@sanity/ui/theme'
import {forwardRef} from 'react'
import {isValidElementType} from 'react-is'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {
responsiveBorderStyle,
ResponsiveBorderStyleProps,
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/code/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {forwardRef} from 'react'
import Refractor from 'react-refractor'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {responsiveCodeFontStyle, ResponsiveFontStyleProps} from '../../styles/internal'
import {codeBaseStyle} from './styles'

Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/container/container.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {Box, BoxProps} from '../box'
import {ResponsiveWidthProps} from '../types'
import {containerBaseStyle, responsiveContainerWidthStyle} from './styles'
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/flex/flex.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {
flexItemStyle,
FlexItemStyleProps,
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/grid/grid.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {responsiveGridStyle, ResponsiveGridStyleProps} from '../../styles/internal'
import {Box, BoxProps} from '../box'
import {ResponsiveGridProps} from '../types'
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/heading/heading.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ThemeFontWeightKey} from '@sanity/ui/theme'
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {
ResponsiveFontStyleProps,
responsiveHeadingFont,
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/inline/inline.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {forwardRef, useMemo, Children} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {Box, BoxProps} from '../box'
import {inlineBaseStyle, inlineSpaceStyle} from './styles'
import {ResponsiveInlineSpaceStyleProps} from './types'
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/kbd/kbd.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {forwardRef} from 'react'
import {styled, css} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
import {Radius} from '../../types'
import {Box} from '../box'
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/label/label.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ThemeFontWeightKey} from '@sanity/ui/theme'
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {responsiveLabelFont, responsiveTextAlignStyle} from '../../styles/internal'
import {TextAlign} from '../../types'
import {labelBaseStyle} from './styles'
Expand Down
3 changes: 2 additions & 1 deletion src/core/primitives/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
useMemo,
useRef,
} from 'react'
import {useArrayProp, useElementSize, useMediaIndex, usePrefersReducedMotion} from '../../hooks'
import {useElementSize, useMediaIndex, usePrefersReducedMotion} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {origin} from '../../middleware/origin'
import {useTheme_v2} from '../../theme'
import {BoxOverflow, CardTone, Placement, PopoverMargins} from '../../types'
Expand Down
3 changes: 2 additions & 1 deletion src/core/primitives/select/select.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {ChevronDownIcon} from '@sanity/icons'
import {forwardRef, useImperativeHandle, useRef} from 'react'
import {styled} from 'styled-components'
import {useCustomValidity, useArrayProp} from '../../hooks'
import {useCustomValidity} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {Radius} from '../../types'
import {Box} from '../box'
import {Text} from '../text'
Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/stack/stack.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {Box, BoxProps} from '../box'
import {stackBaseStyle, responsiveStackSpaceStyle, ResponsiveStackSpaceStyleProps} from './styles'

Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/text/text.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ThemeFontWeightKey} from '@sanity/ui/theme'
import {forwardRef} from 'react'
import {styled} from 'styled-components'
import {useArrayProp} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {
ResponsiveFontStyleProps,
responsiveTextAlignStyle,
Expand Down
3 changes: 2 additions & 1 deletion src/core/primitives/textArea/textArea.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {ThemeFontWeightKey} from '@sanity/ui/theme'
import {forwardRef, useImperativeHandle, useRef} from 'react'
import {styled} from 'styled-components'
import {useCustomValidity, useArrayProp} from '../../hooks'
import {useCustomValidity} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {
responsiveInputPaddingStyle,
responsiveRadiusStyle,
Expand Down
3 changes: 2 additions & 1 deletion src/core/primitives/textInput/textInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {forwardRef, isValidElement, useCallback, useImperativeHandle, useMemo, u
import {isValidElementType} from 'react-is'
import {styled} from 'styled-components'
import {EMPTY_RECORD} from '../../constants'
import {useArrayProp, useCustomValidity} from '../../hooks'
import {useCustomValidity} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {
responsiveRadiusStyle,
ResponsiveRadiusStyleProps,
Expand Down
3 changes: 2 additions & 1 deletion src/core/primitives/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
} from 'react'
import {styled} from 'styled-components'
import {useEffectEvent} from 'use-effect-event'
import {useArrayProp, usePrefersReducedMotion} from '../../hooks'
import {usePrefersReducedMotion} from '../../hooks'
import {useArrayProp} from '../../hooks/useArrayProp'
import {useDelayedState} from '../../hooks/useDelayedState'
import {origin} from '../../middleware/origin'
import {useTheme_v2} from '../../theme'
Expand Down
4 changes: 2 additions & 2 deletions src/core/styles/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export function _responsive<T>(
/**
* @internal
*/
export function _getArrayProp<T = number>(val: T | T[] | undefined, defaultVal?: T[]): T[] {
if (val === undefined) return defaultVal || EMPTY_ARRAY
export function _getArrayProp<T = number>(val: T | T[] | undefined): T[] {
if (val === undefined) return EMPTY_ARRAY

return Array.isArray(val) ? val : [val]
}
Expand Down
Loading
Loading