我在父组件ExpandableListItem
中调用子组件parentscreen.js
。每当我单击可扩展列表项的任何项时,它都会调用getanswer
方法并设置状态{{ 1}}。我的担心是,每当单击子组件中的可扩展列表项的任何一项时,它总是会覆盖questionlistarray
的先前状态,但是我希望先前的状态不应该被覆盖并且应该添加到新状态。>
parentscreen.js
questionlistarray
<View style={{ height: this.state.layout_Height,overflow: 'hidden' }}> {
this.props.item.sub_Category.map((item,key) => (
<View style={styles.sub_Category_Text}>
<Text style={{ fontWeight: 'bold' }}> {item.sub_name} </Text>
{
item.name.map((item1,key) => (
<View>
<Text style={{ marginTop: 10 }}> {item1.question} </Text>
<ExpandableListItem
quesId={item1.question_id}
assignedToList={ this.props.assignedToList}
setanswer={this.getanswer} />
{/* {this.renderQuestions(item1.question_id,this.props.assignedToList)} */} </View>
))
} </View>
))
} </View>