react-select-country-list
react-select-country-list copied to clipboard
Duplicate label when using setEmpty()
When I set an initial empty value like so:
const countries = useMemo(() => {
return countryList().setEmpty("Select a Country").getData();
}, []);
I end up with a duplicate empty value
Am I using the .setEmpty() method wrong?
I messed around with the setEmpty() method and saw that changing to a .concat method instead of .unshift fixed the problem for me. Not sure why. Want me to open a PR or can you think of a cleaner way to do it?
setEmpty(label) {
this.data = [{
value: '',
label: label,
}].concat(this.data)
this.valueMap[''] = label
this.labelMap[label] = ''
return this
}