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

Generic version 4.0.1 #199

Open
noque-lind opened this issue Jul 4, 2024 · 0 comments
Open

Generic version 4.0.1 #199

noque-lind opened this issue Jul 4, 2024 · 0 comments

Comments

@noque-lind
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant