In the componentWillMount I fill in the arraylist from the Fetch API, and I would like to pass a parameter of that filled arraylist (Ex: name), to the title of the Header (navigation), with that code I am not getting. >
import React from 'react';
import { StyleSheet, Text, View, FlatList, TouchableOpacity, StatusBar, Dimensions } from 'react-native';
import ToolbarComponent from 'react-native-toolbar-component';
import { StackNavigator } from 'react-navigation';
export default class telaPrincipal extends React.Component {
static navigationOptions = ({ navigation }) => {
const {state} = navigation.state;
console.log(state)
}
constructor(props){
super(props);
this.state = { dataSource: [] }
}
componentWillMount(){
const { _id } = this.props.navigation.state.params;
fetch('testeApi.com.br')
.then((response) => response.json())
.then((responseJson) => {
const {setParams} = this.props.navigation;
setParams({data: responseJson});
this.setState({
dataSource: responseJson,
}, function(){
});
})
.catch((error) =>{
console.error(error);
});
}
render() {
console.log("Log Principal",this.state.dataSource)
return (
<View style={styles.container}>
</View>
);
}
}