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

Clearing Input causing issue after rerendering #158

Open
jj-apps opened this issue Jan 17, 2025 · 0 comments
Open

Clearing Input causing issue after rerendering #158

jj-apps opened this issue Jan 17, 2025 · 0 comments

Comments

@jj-apps
Copy link

jj-apps commented Jan 17, 2025

Hi! 👋

Firstly, thanks for your work on this project! 🙂

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

I was getting an error "Cannot read property 'id' of undefined"

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-autocomplete-dropdown/src/index.tsx b/node_modules/react-native-autocomplete-dropdown/src/index.tsx
index 8494040..bffcd63 100644
--- a/node_modules/react-native-autocomplete-dropdown/src/index.tsx
+++ b/node_modules/react-native-autocomplete-dropdown/src/index.tsx
@@ -193,9 +193,9 @@ export const AutocompleteDropdown = memo<
 
       let initialValueItem: AutocompleteDropdownItem | undefined
       if (typeof initialValue === 'string') {
-        initialValueItem = initialDataSet?.find(el => el.id === initialValue)
-      } else if (typeof initialValue === 'object' && initialValue.id) {
-        initialValueItem = initialDataSet?.find(el => el.id === initialValue?.id)
+        initialValueItem = initialDataSet?.find(el => el?.id === initialValue)
+      } else if (typeof initialValue === 'object' && initialValue?.id) {
+        initialValueItem = initialDataSet?.find(el => el?.id === initialValue?.id)
         if (!initialValueItem) {
           // set the item as it is if it's not in the list
           initialValueItem = initialValue

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