Здравствуйте, StackOverflow. Я хочу передать данные из моего объекта JSON в свой класс ящика. Я не мог получить доступ к этому объекту в моем втором классе. Я новичок в react native, поэтому любые предложения будут более ценными. 1003 *
class DrawerComponent extends React.Component {
drawerOptions = [
{title: 'About Us', route: 'AboutUs', icon: 'md-card'},
{title: 'Journey Prayers', route: 'Prayers', icon: 'md-ribbon'},
{title: 'Recharge', route: 'Recharge', icon: 'md-cash'},
{title: 'Help Line', route: 'HelpLine', icon: 'md-call'},
{title: 'Media', route: 'Media', icon: 'md-radio'},
{title: 'Motorway Sites', route: 'MotorwaySites', icon: 'md-pin'},
{title: 'Notifications', route: 'Notifications', icon: 'md-notifications'},
];
render() {
return (
<SafeAreaView style = {{flex : 1}}>
<ScrollView>
<View style = {{height : 150 , backgroundColor : 'white' , alignItems : 'center' , justifyContent : 'center'}}>
<Image source = {require('../images/profile.jpg') } style = {{height : 120 , width : 120 ,
borderRadius : 60 , marginTop : 45}} />
//here i want to display username from json object
<Text>Haseeb</Text>
</View>
<View style = {{ marginTop : 30,height : 30 , backgroundColor : 'white' , alignItems : 'center' , justifyContent : 'center'}}>
<Text style= {{fontWeight: 'bold',fontSize: 20,textAlign: 'center'}}>
</Text>
</View>
<View style={{borderBottomColor: '#dedede',marginTop: 25, borderBottomWidth: 1}}/>
<View style={{flex: 1, marginTop: 10}}>
{this.drawerOptions.map(item => (
<TouchableOpacity
style={{padding: 16}}
onPress={() => {
this.props.navigation.toggleDrawer();
this.props.navigation.navigate(item.route);
}}
key={item.title}>
<Text >
<Ionicons name = {item.icon} size={24} style={{color: '#282828'}} />
<Text> </Text>
{item.title}</Text>
</TouchableOpacity>
))}
</View>
</ScrollView>
</SafeAreaView>
);
}
}