I'm trying to get some specific data to appear within some tags but it does NOT show. However, when I console.log the same data that I'm trying to get in the Text tags, I can see it.
Here is my code
import React, { Component } from 'react';
import {
View,
FlatList,
Text
} from 'react-native'
import { NavigationActions } from 'react-navigation';
import { Header } from '../common';
import Config from '../Config';
export default class Costco extends Component {
constructor() {
super();
this.state = {
stores: [],
};
}
componentWillMount() {
const obj = Config.costcoThree;
const costcoArr = Object.values(obj);
this.setState({
stores: costcoArr,
})
}
renderStores(item) {
const navigate = this.props.navigation;
console.log(item.branchName);
return (
<Text>{item.branchName}</Text>
);
}
render(){
return(
<View>
<Header headerText="Costco"/>
<Text>Hello</Text>
<FlatList
data={this.state.stores}
renderItem={({item}) => {
this.renderStores(item)
//return<Text>{item.branchName}</Text>
}}
keyExtractor={(item) => item.id}
/>
</View>
)
}
}
I've tried rendering Text two different ways. The first, was by returning the data between Text tags within the renderItem method. This worked perfectly. However, when I attempt to return the function renderStores, I am not able to see the Text appear. But the data does appear when I console.log it.