-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
i hope can help someone if you want set value default from a existing resource you can this way how explin in documentation
const [countries, setCountries] = React.useState([
{ id: '22946344-f6be-11ed-8207-9828a60f7a9e', name: 'node js'},
{ id: '123456789', name: 'php'}
]);
const id = '22946344-f6be-11ed-8207-9828a60f7a9e';
countries.forEach(function(item){
if ( item.id == id ) {
item.checked = true;
}
});
setCountries(countries);
<Select2
style={{ borderRadius: 5, marginTop: 20 }}
isSelectSingle
cancelButtonText="Cancelar"
selectButtonText="Aceptar"
searchPlaceHolderText="Buscar"
colorTheme={theme.colors.primary}
popupTitle="Seleccione "
title="Selecionar barrio"
data={countries}
onSelect={(data:any) => {
setState(data)
}}
onRemoveItem={(data:any) => {
setState(data)
}}
/>
Metadata
Metadata
Assignees
Labels
No labels