I want to get my object data to header. I parse object data in my componentWillMount() and store it in navigation.setParams(userJSON: object).
My problem is I can see data in header if I just print it as JSON.stringify(object), but when I want to display it as object.name there is a problem..
My code:
componentWillMount() {
    const {
        setParams
    } = this.props.navigation;
    AsyncStorage.getItem('user', (err, result) => {
        this.setState({
            user: JSON.parse(result),
        });
        var obj = JSON.parse(result);
        this.props.navigation.setParams({
            userJSON: obj,
        });
    });
}
Header:
static navigationOptions = ({ navigation }) => ({
    headerTitle: "Tab1",
    headerLeft: (
        <View style={styles.oval}>
            <Text>{JSON.stringify(navigation.getParam('userJSON'))}</Text>
        </View>
    ),
    headerRight: (
      <View style={styles.headerRight}>
        <TouchableOpacity
            title="Ok"
            onPress={() => navigation.navigate('MyProfil')}>
            <View style={styles.circle}>
                <Text style={styles.txtInside}>
                {
                    navigation.getParam('userJSON').name + ''
                    + navigation.getParam('userJSON').lastname
                }
                </Text>
            </View>
        </TouchableOpacity>
      </View>
    )
});
My object is:
{
    id:86163
    lastname:Api
    name:Api
    email:api@eeee.com
    user:api
}
 
     
     
     
    