react-native-select-two icon indicating copy to clipboard operation
react-native-select-two copied to clipboard

set default value from existing resource

Open andresfmm opened this issue 2 years ago • 0 comments

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) }} />

andresfmm avatar May 29 '23 21:05 andresfmm