sohobloo / react-native-modal-dropdown

A react-native dropdown/picker/selector component for both Android & iOS.
MIT License
1.19k stars 477 forks source link

Getting Scroll to index error #263

Open KerryDss opened 3 years ago

KerryDss commented 3 years ago

Hi, I am getting this error from basic implementation .

Here is the error

Invariant Violation: scrollToIndex should be used in conjunction with getItemLayout or onScrollToIndexFailed, otherwise there is no way to know the location of offscreen indices or handle failures.

Here is the screen shot

Simulator Screen Shot - iPhone 12 - 2021-08-09 at 14 23 09

Here is the code

<SafeAreaView>
<View>
        <Text style={{position: 'absolute', top: 40, left: 20}}>
           Shop By :
         </Text>
                <ModalDropdown
                  style={{
                    marginTop: 30,
                    borderWidth: 1,
                    paddingVertical: 8,
                    // paddingLeft: 12,
                    borderRadius: 12,
                    borderColor: 'grey',
                  }}
            textStyle={[globalStyle.boldedFont, globalStyle.normalText, {paddingLeft: 86}]}
                  defaultValue=" "
                  dropdownStyle={{
                    width: windowWidth - 32,
                    height: 70,
                    marginLeft: -2,
                  }}
                  options={['Top Brands', 'Brands with Promotions']}
                />
        </View>
</SafeAreaView>

This error occur when you try to change the value multiple times.

van1985 commented 3 years ago

Any news about this issue? I have experimenting the same issue :(

trusasha commented 3 years ago

Try to add prop saveScrollPosition={false} to ModalDropdown This work for me (1.0.1 version)

HammadAhm3d commented 3 years ago

Try to add prop saveScrollPosition={false} to ModalDropdown This work for me (1.0.1 version)

Thanks. Worked for me too.