我正在尝试映射“ socialMediaDetail”数组并获取其名称。此数组中有任何值。现在,我试图从该数组中获取Twitter,然后在状态中获取该值。我该怎么办,请帮忙。
下面是数组vakue
socialMediaDetails:
socialMediaDetail: Array(5)
0:
link: "HARIRAM@twitter.com"
name: "twitter"
__typename: "SocialMediaDetail"
__proto__: Object
1:
link: "VarnaHERO@facebook.com"
name: "facebook"
__typename: "SocialMediaDetail"
__proto__: Object
2:
link: "linkedIn@linkedin.com"
name: "linkedIn"
__typename: "SocialMediaDetail"
下面是代码
class UpdateNotificationpreference extends Component {
constructor(props) {
super(props);
const{navigation}=this.props;
const{contactDetails,socialMediaDetails}= navigation.state.params.customerInfo[0];
const{socialMediaDetail}=socialMediaDetails;
socialMediaDetail.map((data, index) => {
const twitter= data.name==="twitter";
});
this.state = {
title: 'Update Notification Preference',
mobile: navigation.state.params.serviceNumber,
icon: 'sim',
isChecked: false,
facebook: navigation.state.params.customerInfo[0].socialMediaDetails.socialMediaDetail[1].name==="facebook"?true : false,
isTwitter:this.twitter==="twitter"?true:false,
render(){
return(
{this.state.isTwitter === true &&
<View style={{marginTop:15}}>
<Label img={FAX_MINI} textLabel="FAX"/>
<Item style={{borderColor: '#00fff', borderBottomWidth:1, marginLeft:0}}>
<Input
value={this.state.faxNum}
onChangeText={(text) => this.setState({faxNum:text})}
/>
</Item>
</View>}
)
}
谢谢