Skip to content

Commit

Permalink
Merge pull request #533 from JDMathew/patch-1
Browse files Browse the repository at this point in the history
Updated setState types
  • Loading branch information
hossein-zare authored Apr 7, 2022
2 parents c8d31ec + eb919cf commit 67e605e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module 'react-native-dropdown-picker' {
import type { SetStateAction, Dispatch, PropsWithoutRef } from 'react';
import type { Dispatch, PropsWithoutRef } from 'react';
import type {
FlatListProps,
LayoutChangeEvent,
Expand All @@ -14,6 +14,9 @@ declare module 'react-native-dropdown-picker' {
ViewStyle,
} from 'react-native';

type SetStateCallback<S> = ((prevState: S) => S);
type SetStateValue<S> = ((prevState: S) => S);

export type ValueType = string | number | boolean;

export type ItemType<T> = {
Expand Down Expand Up @@ -243,8 +246,8 @@ declare module 'react-native-dropdown-picker' {
min?: number;
max?: number;
addCustomItem?: boolean;
setOpen: Dispatch<SetStateAction<boolean>>;
setItems?: Dispatch<SetStateAction<any[]>>;
setOpen: Dispatch<SetStateValue<boolean>>;
setItems?: Dispatch<SetStateCallback<any[]>>;
disableBorderRadius?: boolean;
containerProps?: ViewProps;
onLayout?: (e: LayoutChangeEvent) => void;
Expand All @@ -268,15 +271,15 @@ declare module 'react-native-dropdown-picker' {
multiple?: false;
onChangeValue?: (value: T | null) => void;
onSelectItem?: (item: ItemType<T>) => void;
setValue: Dispatch<SetStateAction<T | null>>;
setValue: Dispatch<SetStateCallback<T | null | any>>;
value: T | null;
}

interface DropDownPickerMultipleProps<T> {
multiple: true;
onChangeValue?: (value: T[] | null) => void;
onSelectItem?: (items: ItemType<T>[]) => void;
setValue: Dispatch<SetStateAction<T[] | null>>;
setValue: Dispatch<SetStateCallback<T[] | null | any>>;
value: T[] | null;
}

Expand Down

0 comments on commit 67e605e

Please sign in to comment.