Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set state action types #705

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
| 'FR'
| 'ID'
| 'IT'
| 'KO'
| 'PT'
| 'RU'
| 'TR'
| 'KO';
| 'TR';

export interface TranslationInterface {
NOTHING_TO_SHOW: string;
Expand Down Expand Up @@ -155,9 +158,9 @@

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 @@
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 All @@ -295,7 +298,7 @@
addTranslation: (
language: string,
translation: TranslationInterface,
) => void;

Check failure on line 301 in index.d.ts

View workflow job for this annotation

GitHub Actions / Lint source files

File has too many lines (331). Maximum allowed is 300
DROPDOWN_DIRECTION: DropDownDirectionType;
LANGUAGE: LanguageType;
LIST_MODE: ListModeInterface;
Expand Down
Loading