Skip to content

Commit

Permalink
fix: corrected SetStateCallback and SetStateValue to SetStateAction i…
Browse files Browse the repository at this point in the history
…n types (#705)

* sorted items in LanguageType

* added SetStateAction to types in index.d.ts
  • Loading branch information
taeh98 authored Sep 5, 2023
1 parent 83a0adc commit e3f4d09
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
declare module 'react-native-dropdown-picker' {

Check failure on line 1 in index.d.ts

View workflow job for this annotation

GitHub Actions / Lint source files

Missing @file
import { Dispatch, JSX, PropsWithoutRef, ReactElement } from 'react';
import {
Dispatch,
JSX,
PropsWithoutRef,
ReactElement,
SetStateAction,
} from 'react';
import {
FlatListProps,
LayoutChangeEvent,
Expand All @@ -14,9 +20,6 @@ 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 extends ValueType> = {
Expand Down Expand Up @@ -70,10 +73,10 @@ declare module 'react-native-dropdown-picker' {
| 'FR'
| 'ID'
| 'IT'
| 'KO'
| 'PT'
| 'RU'
| 'TR'
| 'KO';
| 'TR';

export interface TranslationInterface {
NOTHING_TO_SHOW: string;
Expand Down Expand Up @@ -155,9 +158,9 @@ declare module 'react-native-dropdown-picker' {

export interface DropDownPickerBaseProps<T extends ValueType> {
items: Array<ItemType<T>>;
setItems?: Dispatch<SetStateCallback<Array<ItemType<T>>>>;
setItems?: Dispatch<SetStateAction<Array<ItemType<T>>>>;
open: boolean;
setOpen: Dispatch<SetStateValue<boolean>>;
setOpen: Dispatch<SetStateAction<boolean>>;
activityIndicatorColor?: string;
ActivityIndicatorComponent?: (
props: ActivityIndicatorComponentPropsInterface,
Expand Down Expand Up @@ -278,15 +281,15 @@ declare module 'react-native-dropdown-picker' {
multiple?: false;
onChangeValue?: (value: T | null) => void;
onSelectItem?: (item: ItemType<T>) => void;
setValue: Dispatch<SetStateCallback<T | null>>;
setValue: Dispatch<SetStateAction<T | null>>;
value: T | null;
}

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

Expand Down

0 comments on commit e3f4d09

Please sign in to comment.