diff --git a/src/hooks/useControlledState/useControlledState.ts b/src/hooks/useControlledState/useControlledState.ts index 60a8555b7a..67fbdb8283 100644 --- a/src/hooks/useControlledState/useControlledState.ts +++ b/src/hooks/useControlledState/useControlledState.ts @@ -1,19 +1,19 @@ import React from 'react'; -export function useControlledState( +export function useControlledState( value: Exclude, defaultValue: Exclude | undefined, - onChange?: (v: C, ...args: any[]) => void, -): [T, (value: C) => void]; -export function useControlledState( + onChange?: (v: C, ...args: Args) => void, +): [T, (value: C, ...args: Args) => void]; +export function useControlledState( value: Exclude | undefined, defaultValue: Exclude, - onChange?: (v: C, ...args: any[]) => void, -): [T, (value: C) => void]; -export function useControlledState( + onChange?: (v: C, ...args: Args) => void, +): [T, (value: C, ...args: Args) => void]; +export function useControlledState( value: T, defaultValue: T, - onUpdate?: (value: C, ...args: any[]) => void, + onUpdate?: (value: C, ...args: Args) => void, ) { const [innerValue, setInnerValue] = React.useState(value ?? defaultValue); @@ -37,7 +37,7 @@ export function useControlledState( // that we call `onUpdate` inside the callback function and onUpdate // in a controlling component frequently calls setState itself, // therefore we call `setState` while we're rendering a different component. - (newValue: C, ...args: any[]) => { + (newValue: C, ...args: Args) => { if (!Object.is(currentValue, newValue)) { onUpdate?.(newValue, ...args); }