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

Invariant Violation: scrollToIndex out of range: requested index 101 is out of 0 to 36 #22

Closed
govindshah62 opened this issue Nov 27, 2021 · 15 comments

Comments

@govindshah62
Copy link

I am using a dropdown for the country data and it contains more than 150 data, without search, it is working fine but with search it is throwing error of " Invariant Violation: scrollToIndex out of range: requested index 101 is
out of 0 to 36 "

import { Dropdown } from 'react-native-element-dropdown';
import { ScrollView, Text, TextInput, View } from 'react-native';

return (

<Text style={[styles.regularText, styles.f15]} numberOfLines={1}>
Country/Region

<Dropdown
style={[styles.dropdown, styles.lightText]}
data={allCountries}
labelField="label"
valueField="label"
placeholder="Select Country"
value={country}
onChange={(item) => {
setcountry(item.label);
}}
renderItem={_renderItem}
selectedTextStyle={[styles.selectedText, styles.mediumText]}
placeholderStyle={[styles.selectedText, styles.mediumText]}
maxHeight={300}
search
autoScroll={true}
searchPlaceholder="Search..."
inputSearchStyle={{ height: 40, fontSize: 13, }}
iconColor={colors.primary}
/>

      {/* <Text style={[styles.regularText, styles.errorTextStyle]}>Error message</Text> */}
    </View>

)
WhatsApp Image 2021-11-27 at 11 24 44 AM

@hoaphantn7604
Copy link
Owner

I'm working on it.

@hoaphantn7604
Copy link
Owner

This issue has been resolved. Please install later version 1.5.4

@govindshah62
Copy link
Author

yes now it's working, Thanks !!

@govindshah62
Copy link
Author

now its again getting the same error if we use 2 dropdowns with search functionality

steps to reproduce:
1). The First dropdown is for country and 2 is for the state
2). Now first search in the country dropdown and then in state dropdown
3). Now if we again search in the country dropdown it throws the same error

@hoaphantn7604
Copy link
Owner

Thanks, I'm working on it.

@hoaphantn7604
Copy link
Owner

Can you give me sample code?

@hoaphantn7604
Copy link
Owner

I cannot reproduce this error. Please provided video.

@hoaphantn7604
Copy link
Owner

Please install version 1.5.5.
I'm not sure it worked.
You can try again and feedback for me

@akshy78695
Copy link

I'm also getting this error but only when I set predefine dropdown value, If dropdown value is empty it works perfectly.

react-native-element-version: 1.5.8
react: 17.0.2
react-native: 0.66.4

@hoaphantn7604
Copy link
Owner

hi @akshy78695 ,
I'm working on it.

@hoaphantn7604
Copy link
Owner

hi @akshy78695 ,
I can't reproduce your problem, but i have updated a few things hope it will work for you.
Please instal later version.

@govindshah62
Copy link
Author

hi @hoaphantn7604 now getting same error with different condition
steps to produce:-

  1. Load a list of 250+ elements
  2. now search last element and select it
  3. now search for the 1st element and try to select it, it will throw error

@krishna-kpk
Copy link

In library components Dropdown directory index.tsx file, if you added Flatlist props initialNumToRender={listData.length} then you are able to auto-scroll to 250 or 300 records. Also if we added props for this functionality that's helpful to user who is use this library.

@floppy1515
Copy link

This dropdown library is great but I have the same problem,
I have a list of 1000 countries when the user quickly presses three letters I find the expression:

ERROR Invariant Violation: scrollToIndex out of range: item length 0 but minimum is 1, js engine: hermes

@Karan-zymr
Copy link

Karan-zymr commented Apr 26, 2024

@hoaphantn7604 This issue is still there if the options list is long. Please review this PR as it has a potential solution for the error: #253

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

6 participants