react-native-infinite-looping-scroll
react-native-infinite-looping-scroll copied to clipboard
The readme example throws "data is not defined"
React Native v0.64.3 on Expo using this code:
import { Modal, StyleSheet, Text, View } from 'react-native';
import { CustomButton } from 'src/components/Buttons/CustomButton';
import InfiniteScroll from 'react-native-infinite-looping-scroll';
interface Params {
visible: boolean;
setTimePickerVisible: any;
}
export const TimePicker = ({ visible, setTimePickerVisible }: Params) => {
return (
<Modal
animationType="slide"
transparent={true}
visible={visible}
onRequestClose={() => setTimePickerVisible(!visible)}
>
<View>
<Text>Select time</Text>
<View>
<InfiniteScroll
data={[{ key: '1' }, { key: '2' }, { key: '3' }, { key: '4' }, { key: '5' }, { key: '6' }, { key: '7' }]}
renderItem={({ item }: any) => (
<View>
<Text>{item.key}</Text>
</View>
)}
/>
</View>
<CustomButton title={'Set time'} onPressFunction={() => setTimePickerVisible(!visible)} />
</View>
</Modal>
);
};
Throws
Uncaught ReferenceError: data is not defined at new InfiniteScroll (index.js:13) at constructClassInstance (react-dom.development.js:12716) at updateClassComponent (react-dom.development.js:17425) at beginWork (react-dom.development.js:19073) at HTMLUnknownElement.callCallback (react-dom.development.js:3945) at Object.invokeGuardedCallbackDev (react-dom.development.js:3994) at invokeGuardedCallback (react-dom.development.js:4056) at beginWork$1 (react-dom.development.js:23964) at performUnitOfWork (react-dom.development.js:22779) at workLoopSync (react-dom.development.js:22707) at renderRootSync (react-dom.development.js:22670) at performSyncWorkOnRoot (react-dom.development.js:22293) at react-dom.development.js:11327 at unstable_runWithPriority (scheduler.development.js:468) at runWithPriority$1 (react-dom.development.js:11276) at flushSyncCallbackQueueImpl (react-dom.development.js:11322) at flushSyncCallbackQueue (react-dom.development.js:11309) at discreteUpdates$1 (react-dom.development.js:22420) at discreteUpdates (react-dom.development.js:3756) at dispatchDiscreteEvent (react-dom.development.js:5889)

