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

Console warnings about initialScrollIndex "-1" is not valid #232

Closed
floatplane opened this issue Oct 18, 2023 · 2 comments
Closed

Console warnings about initialScrollIndex "-1" is not valid #232

floatplane opened this issue Oct 18, 2023 · 2 comments

Comments

@floatplane
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @mobile-reality/react-native-select-pro@2.2.2 for the project I'm working on.

I was seeing frequent warnings in my console when activating the dropdown. Here's an example:

 WARN  initialScrollIndex "-1" is not valid (list has 2 items) 
    at VirtualizedList (http://127.0.0.1:8081/node_modules/expo/AppEntry.bundle//&platform=ios&dev=true&hot=false&lazy=true:75000:36)
    at FlatList (http://127.0.0.1:8081/node_modules/expo/AppEntry.bundle//&platform=ios&dev=true&hot=false&lazy=true:74308:36)
    at FlatOptionsList (http://127.0.0.1:8081/node_modules/expo/AppEntry.bundle//&platform=ios&dev=true&hot=false&lazy=true:155029:26)
    at RCTView
    at View (http://127.0.0.1:8081/node_modules/expo/AppEntry.bundle//&platform=ios&dev=true&hot=false&lazy=true:63539:43)
    at AnimatedView (http://127.0.0.1:8081/node_modules/expo/AppEntry.bundle//&platform=ios&dev=true&hot=false&lazy=true:71247:62)
    at OptionsListWrapper (http://127.0.0.1:8081/node_modules/expo/AppEntry.bundle//&platform=ios&dev=true&hot=false&lazy=true:155382:24)
    at OptionsList (http://127.0.0.1:8081/node_modules/expo/AppEntry.bundle//&platform=ios&dev=true&hot=false&lazy=true:154903:59)

Here is the diff that solved my problem:

diff --git a/node_modules/@mobile-reality/react-native-select-pro/src/components/options-list/options-list.tsx b/node_modules/@mobile-reality/react-native-select-pro/src/components/options-list/options-list.tsx
index b58d6ad..83fb6d7 100644
--- a/node_modules/@mobile-reality/react-native-select-pro/src/components/options-list/options-list.tsx
+++ b/node_modules/@mobile-reality/react-native-select-pro/src/components/options-list/options-list.tsx
@@ -128,7 +128,7 @@ export const OptionsList = forwardRef<View>((_, optionsListRef) => {
                 />
             ) : (
                 <FlatOptionsList
-                    initialScrollIndex={initialScrollIndex}
+                    initialScrollIndex={initialScrollIndex === -1 ? undefined : initialScrollIndex}
                     getItemLayout={getItemLayout}
                     renderItem={renderFlatItem}
                     accessibilityState={accessibilityState}

This issue body was partially generated by patch-package.

@efstathiosntonas
Copy link
Contributor

duplicate: #214

@gitsad
Copy link
Contributor

gitsad commented Nov 23, 2023

fixed in #233

@gitsad gitsad closed this as completed Nov 23, 2023
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

3 participants