Skip to content

Commit 67e605e

Browse files
authored
Merge pull request hossein-zare#533 from JDMathew/patch-1
Updated setState types
2 parents c8d31ec + eb919cf commit 67e605e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

index.d.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module 'react-native-dropdown-picker' {
2-
import type { SetStateAction, Dispatch, PropsWithoutRef } from 'react';
2+
import type { Dispatch, PropsWithoutRef } from 'react';
33
import type {
44
FlatListProps,
55
LayoutChangeEvent,
@@ -14,6 +14,9 @@ declare module 'react-native-dropdown-picker' {
1414
ViewStyle,
1515
} from 'react-native';
1616

17+
type SetStateCallback<S> = ((prevState: S) => S);
18+
type SetStateValue<S> = ((prevState: S) => S);
19+
1720
export type ValueType = string | number | boolean;
1821

1922
export type ItemType<T> = {
@@ -243,8 +246,8 @@ declare module 'react-native-dropdown-picker' {
243246
min?: number;
244247
max?: number;
245248
addCustomItem?: boolean;
246-
setOpen: Dispatch<SetStateAction<boolean>>;
247-
setItems?: Dispatch<SetStateAction<any[]>>;
249+
setOpen: Dispatch<SetStateValue<boolean>>;
250+
setItems?: Dispatch<SetStateCallback<any[]>>;
248251
disableBorderRadius?: boolean;
249252
containerProps?: ViewProps;
250253
onLayout?: (e: LayoutChangeEvent) => void;
@@ -268,15 +271,15 @@ declare module 'react-native-dropdown-picker' {
268271
multiple?: false;
269272
onChangeValue?: (value: T | null) => void;
270273
onSelectItem?: (item: ItemType<T>) => void;
271-
setValue: Dispatch<SetStateAction<T | null>>;
274+
setValue: Dispatch<SetStateCallback<T | null | any>>;
272275
value: T | null;
273276
}
274277

275278
interface DropDownPickerMultipleProps<T> {
276279
multiple: true;
277280
onChangeValue?: (value: T[] | null) => void;
278281
onSelectItem?: (items: ItemType<T>[]) => void;
279-
setValue: Dispatch<SetStateAction<T[] | null>>;
282+
setValue: Dispatch<SetStateCallback<T[] | null | any>>;
280283
value: T[] | null;
281284
}
282285

0 commit comments

Comments
 (0)