I am trying to create a pin lock screen. The problem occured in the num pads section.it said "Each child in a list should have a unique "key" prop." I have no idea what's wrong with my code.
here is my list for the number pads.
render() {
let numberPads = [
{id: 1,value: '1', style: styles.numPad},
{ id: 2,value: '2', style: styles.numPad },
{ id: 3,value: '3', style: styles.numPad },
{ id: 4,value: '4', style: styles.numPad },
{ id: 5,value: '5', style: styles.numPad },
{ id: 6,value: '6', style: styles.numPad },
{ id: 7,value: '7', style: styles.numPad },
{ id: 8,value: '8', style: styles.numPad },
{ id: 9,value: '9', style: styles.numPad },
{ id: 10,value: '', style: styles.keyPad },
{ id: 11,value: '0', style: styles.numPad },
{ id: 12,value: '11', style: styles.keyPad }
]
return (........) }
here is how the number pads above is rendered.
render(){
......
return(
.....
<View style={styles.numPadContainer}>
{numberPads.map(numberPad => {
let numPad = numberPad.id != 12 ?
<TouchableOpacity style={numberPad.style} key={numberPad.id}
onPress={() => this.onPressNumberPad(numberPad.value)}
>
<Text style={styles.numText} >{numberPad.value}</Text>
</TouchableOpacity> :
<TouchableOpacity style={numberPad.style} key={numberPad.id}
onPress={() => this.onPressDeletePad()}
>
<Image source={require('../assets/images/clear-icon-50px.png')} />
</TouchableOpacity>
return (
numPad
)
})}
</View>
......
)
}