Gabotronix's avatar

React Native. undefined is not an object (evaluating '_this.props.updateCellsBatchingPeriod')

Hi everybody, I have a react-native app created with RN CLI, using react-native 0.63, I'm trying to use SectionList but I'm getting the following error:

undefined is not an object (evaluating '_this.props.updateCellsBatchingPeriod')

Full error:

https://i.imgur.com/oAPvG9e.png

My code is pretty simple and the trace obviously points to SectionList being the problem.

return (
    <View style={{ flex:1, backgroundColor:'white' }}>
        <SectionList style={{ flex:1,backgroundColor:'rgb(235,235,235)' }} showsVerticalScrollIndicator={false} 
        sections={[{ title: 'Title', data: [ { id:1 },{ id:2 } ]}]}
        />
    </View>
    );

I remember this code working perfectly in my old expo app but now the same code fails

I found this in github but I'm not using Typescript so ...

https://github.com/facebook/react-native/issues/29437

0 likes
1 reply
CorvS's avatar

You have to define how your items are rendered using renderItem.

...
renderItem={({ item }) => <Text>item.id</Text>}
...

And make sure to define how the item key is extracted:

...
keyExtractor={item => item.id}
...

Please or to participate in this conversation.