I have a state this.state.mantras
which gets updated everytime I post a new mantra
.
I have a component with a FlatList to render each of the mantras. However, the FlatList is not rendering anything. I am able to console.log the state which logs the updated state of the mantras array every time.
I have a feeling that it's caused by something to do with react-native-tab-view within which I am trying to render the flatlist.
SecondRoute = () => (
<FlatList
keyExtractor={(item, index) => index.toString()}
numColumns={1}
data={this.state.mantras}
renderItem={this._renderItem}
/>
)
render() {
console.log(this.state) <-- success
return (
<TabView
renderTabBar={props =>
<TabBar
bounces
{...props}
style={styles.tabStyle}
/>
}
navigationState={this.state}
renderScene={SceneMap({
second: this.SecondRoute, <--- fails to render, no errors
})}
onIndexChange={index => this.setState({ index })}
initialLayout={{ width: Dimensions.get('window').width }}
/>
)
}
_renderItem = ({item, index}) => (
<View>
<View style={styles.mantraCard} key={item.id}>
<Text style={styles.title}>{item.title}</Text>
<Text style={styles.description}>{item.description}</Text>
</View>
</View>
);