React-native-picker-select: Each child in a list should have a unique "key" prop.

Created on 2 Aug 2019  路  2Comments  路  Source: lawnstarter/react-native-picker-select

I ready set key but it's alway error
Each child in a list should have a unique "key" prop.

const itemsTest = [
    { label: '1', value: '1', key: 1 },
    { label: '2', value: '2', key: 2 },
    { label: '3', value: '3', key: 3 },
    { label: '4', value: '4', key: 4 },
]
class PickerSelect extends Component {
    render() {
        return (
            <View style={Styles.picker}>
                <RNPickerSelect
                    placeholderTextColor={Colors.colorPlaceholder}
                    placeholder={{ label: this.props.textPlacehoder, color: Colors.colorPlaceholder }}
                    items={this.props.itemsTest}
                    onValueChange={(value, index) => this.props.onValueChange(value)}
                />
            </View>
        );
    }
};

Most helpful comment

Just encountred this. Make sure the value of label in placeholder object is not nil, it will be used as a key, In your case the this.props.textPlacehoder. Or you can add key to the placeholder object, then it will be used.

All 2 comments

Use the bug report template

Just encountred this. Make sure the value of label in placeholder object is not nil, it will be used as a key, In your case the this.props.textPlacehoder. Or you can add key to the placeholder object, then it will be used.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sebqq picture sebqq  路  9Comments

Unforgiven-wanda picture Unforgiven-wanda  路  4Comments

ltsharma picture ltsharma  路  3Comments

karajaNaji picture karajaNaji  路  3Comments

dakairus picture dakairus  路  3Comments