having the code below, how can I display the various properties on the mobile screen? I'm able to see the array of objects printed out on the console, but I'm not able to use the properties contained in each object in order to display the information on the mobile screen.
import React, { Component } from 'react';
import { AppRegistry, ListView, View, Text } from 'react-native';
import axios from 'axios';
export default class Component5 extends Component {
constructor() {
super();
const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
this.state = {
userDataSource: ds,
};
}
componentDidMount() {
this.fetchUsers();
}
fetchUsers() {
axios.get('https://stageapi6.devmn.net/api/v1/forums/threads?topic_id=2418', {
headers: {
'client-id': '********'
}
})
.then(response => this.setState({ userDataSource: this.state.userDataSource.cloneWithRows(response) }));
}
renderRow = (user) => {
console.log(user); // => [Object, Object, Object, Object .........]
return (
<View>
{/* I need a way to iterate the bojects and display the properties inside teh Text tags, the code below doesn't work */}
<Text>{user.thread.num_posts}</Text>
<Text>{user.thread.topic_name}</Text>
<Text>{user.thread.name}</Text>
</View>
);
}
render() {
return (
<ListView
dataSource={this.state.userDataSource}
renderRow={(user) => this.renderRow(user.threads)}
/>
);
}
}
AppRegistry.registerComponent('Component5', () => Component5);
SCREENSHOT OF THE RETURNED ARRAY OF OBJECTS AND ITS PROPERTIES
