Reputation: 141
I'm trying to call a method to fill a View element with a Text element in React Native by returning it in a method:
< View>{this._getCategories(item)}< /View>
The _getCategories method returns a Text element after it uses the item parameter to retrieve the correct data. A simplified version would look like this:
_getCategories = item => {
names = 'some string';
console.log(names); //this logs the correct string
return <Text style={styles.categories}>{names}</Text>;
};
The Text element does not appear in the application, shows undefined if I use {String(names)} in the View element.
Upvotes: 0
Views: 365
Reputation: 522
Tried both {String(names)}
and {names}
, it works fine. May be there is a problem in your retrieving method.
Upvotes: 1