소개
게시글
질문&답변
2021.01.25
return()
map 돌릴 때 undefined is not an object 뜨시는 것은 아래처럼 물음표 넣어주시면 될 거 같아요. {item.phoneNumbers[0]?.number}
- 0
- 5
- 322
질문&답변
2021.01.25
return()
이렇게 말씀이신가요? {}로 감싸져 있기에 return이 2개 나 n개 인거는 문제가 아닌 거 같아요. render(){ return ( View style={styles.container}> Text onPress={this.changeState} style={styles.text}>{this.state.sampleText}Text> {this.inputText()} Text onPress={this.onAdd} style={styles.text}>{this.state.sampleNum}Text> Text onPress={this.changeState} style={styles.text}>{this.state.sampleText}Text> {this.inputText()} Text onPress={this.onAdd} style={styles.text}>{this.state.sampleNum}Text> PropsChild sampleText={this.state.sampleText} changeState={this.changeState}/> Image source={{uri:this.state.avatar}} style={styles.avatar}> Image> Button title="Add an Image" onPress={()=>this.addImage()} /> Text onPress={this.onAdd} style={styles.text}>{this.state.avatar}Text> { this.state.myContacts.map((item, idx)=>{ return( Text key={idx}> {idx} {item.givenName} {item.phoneNumbers[0]?.number} Text> ) }) } Text> aaaa Text> Button title="Load Contacts" onPress={()=>this.getContacts()} /> View> ) }
- 0
- 5
- 322