From 7aadd662d3af3ceadca296e653016edf19f053ce Mon Sep 17 00:00:00 2001 From: Robert Snow Date: Wed, 31 Jul 2024 12:43:55 +1000 Subject: [PATCH] Fix type regression on useControlledState signature (#6789) --- packages/@react-stately/utils/src/useControlledState.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@react-stately/utils/src/useControlledState.ts b/packages/@react-stately/utils/src/useControlledState.ts index ab8b2bbb12e..f88f3aa3852 100644 --- a/packages/@react-stately/utils/src/useControlledState.ts +++ b/packages/@react-stately/utils/src/useControlledState.ts @@ -12,9 +12,9 @@ import {useCallback, useEffect, useRef, useState} from 'react'; -export function useControlledState(value: Exclude, defaultValue: Exclude | undefined, onChange?: (v: C, ...args: any[]) => void): [T, (value: T) => void]; -export function useControlledState(value: Exclude | undefined, defaultValue: Exclude, onChange?: (v: C, ...args: any[]) => void): [T, (value: T) => void]; -export function useControlledState(value: T, defaultValue: T, onChange?: (v: C, ...args: any[]) => void): [T, (value: T) => void] { +export function useControlledState(value: Exclude, defaultValue: Exclude | undefined, onChange?: (v: C, ...args: any[]) => void): [T, (value: T, ...args: any[]) => void]; +export function useControlledState(value: Exclude | undefined, defaultValue: Exclude, onChange?: (v: C, ...args: any[]) => void): [T, (value: T, ...args: any[]) => void]; +export function useControlledState(value: T, defaultValue: T, onChange?: (v: C, ...args: any[]) => void): [T, (value: T, ...args: any[]) => void] { let [stateValue, setStateValue] = useState(value || defaultValue); let isControlledRef = useRef(value !== undefined);