`scrollToIndex` error when set the default value over the certain index for a list over 41 items.
Hi,
I notice there is a bug when I try to set the defaultValue to the 41th element in the data list.
This can be reproduced by the following code
const MySelection = () => {
const data = useMemo(() => {
let arr = []
for (let i = 0; i < 100; i++) {
arr.push(i.toString());
}
return arr;
}, [])
return <SelectDropdown
data={data}
onSelect={(selectedItem, index) => {
console.log(selectedItem, index);
}}
defaultValue={"40"}
renderButton={(selectedItem, isOpened) => (<View><Text>{selectedItem || 'Change me'}</Text></View>)}
renderItem={(item, index, isSelected) => (<View><Text>{item}</Text></View>)
}
showsVerticalScrollIndicator={true}
/>
};
This is the error page from the iPhone simulator.
Based on the error message, it seems like before running scrollToIndex, there should be a getItemLayout being used.
I am happy to open a PR to fix this if you preferred. Thanks
https://github.com/AdelRedaa97/react-native-select-dropdown/commit/6bafb535d006e8bbdffc26bb2755acaba9067a07#r140439325
I removed it by mistake I will add it again
Sounds great, also noticed that comments here seem wrong to the functions (just need to exchange them.)
@AdelRedaa97 , Hello, is this updated yet? I still get this error
yes, Just fixed in v 4.0.1 try it and reopen the issue if its still existed