Open atasmohammadi opened 8 years ago
Whenever you create a list of objects you need to add a unique key. There is a second parameter that contains it
renderRow(data, key) {
var header = (
<View key={key}>
<View style={styles.rowContainer}>
<View style={styles.textContainer}>
<Text style={styles.title}>{data.nid}</Text>
<Text style={styles.description} numberOfLines={0}>{data.title}</Text>
</View>
</View>
<View style={styles.separator}/>
</View>
);
you would also need to do that for the content
var content = [];
for(var x=0; x < Object.keys(data.course).length; x++){
content.push(
<View key={x} style={styles.rowContainer}>
<TouchableHighlight onPress={() => this.rowPressed(data.course[x].course_id).bind(this)} underlayColor='#e3e0d7'>
<Text style={styles.child}>{data.course[x].title}</Text>
</TouchableHighlight>
</View>
);
}
Hello,
My Code is down bellow. its working but i got two warnings :
Warning: Failed propType: Invalid prop
content
supplied toAccordion
, expected a single ReactElement. Check the render method ofStaticRenderer
.Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of
Accordion
. It was passed a child from StaticRenderer. See https://fb.me/react-warning-keys for more information.Any idea how to fix it? or any better way to have multiple contents for each header?
Thanks in Advance!