AdelRedaa97 / react-native-select-dropdown

react-native-select-dropdown is a highly customized dropdown | select | picker | menu for react native that works for andriod and iOS platforms.
MIT License
312 stars 133 forks source link

Generic version 4.0.1 #199

Open noque-lind opened 6 days ago

noque-lind commented 6 days ago

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch react-native-select-dropdown@4.0.1 for the project I'm working on.

to make it generic.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-select-dropdown/index.d.ts b/node_modules/react-native-select-dropdown/index.d.ts
index f5c89c4..bc00448 100644
--- a/node_modules/react-native-select-dropdown/index.d.ts
+++ b/node_modules/react-native-select-dropdown/index.d.ts
@@ -2,27 +2,27 @@ import type * as React from 'react';
 import {StyleProp, ViewStyle, TextStyle} from 'react-native';

 declare module 'react-native-select-dropdown' {
-  export type SelectDropdownProps = {
+  export type SelectDropdownProps<T> = {
     /**
      * array of data that will be represented in dropdown, can be array of objects
      */
-    data: Array<any>;
+    data: Array<T>;
     /**
      * function recieves selected item and its index in data array
      */
-    onSelect: (selectedItem: any, index: number) => void;
+    onSelect: (selectedItem: T, index: number) => void;
     /**
      * function returns React component for the dropdown button
      */
-    renderButton: (selectedItem: any, isOpened: boolean) => React.ReactNode;
+    renderButton: (selectedItem: T, isOpened: boolean) => React.ReactNode;
     /**
      * function returns React component for each dropdown item
      */
-    renderItem: (selectedItem: any, index: number, isSelected: boolean) => React.ReactNode;
+    renderItem: (selectedItem: T, index: number, isSelected: boolean) => React.ReactNode;
     /**
      * default selected item in dropdown
      */
-    defaultValue?: any;
+    defaultValue?: T;
     /**
      * default selected item index
      */
@@ -102,14 +102,14 @@ declare module 'react-native-select-dropdown' {
     /**
      * function returns React component for search input icon
      */
-    renderSearchInputLeftIcon?: (selectedItem: any, index: number) => React.ReactNode;
+    renderSearchInputLeftIcon?: (selectedItem: T, index: number) => React.ReactNode;
     /**
      * function returns React component for search input icon
      */
-    renderSearchInputRightIcon?: (selectedItem: any, index: number) => React.ReactNode;
+    renderSearchInputRightIcon?: (selectedItem: T, index: number) => React.ReactNode;
   };

-  export default class SelectDropdown extends React.Component<SelectDropdownProps> {
+  export default class SelectDropdown<T> extends React.Component<SelectDropdownProps<T>> {
     /**
      * Remove selection & reset it
      */

This issue body was partially generated by patch-package.