Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
React Native: ¿Hay alguna forma de restablecer el selector al estado inicial?

¿Hay alguna manera de restablecer el selector al estado inicial en el que se mostró por primera vez cuando hice clic en onChangeCheckbox? En mi ejemplo, muestro la casilla de verificación y también el selector y solo necesito mostrar la información inicial que estaba en el selector cuando entré en la pantalla.

ESTA ES LA CASILLA

 const onChangeCheckbox = (n, newValue, item) => { console.log('onChangeCheckbox n,newValue: ', n, newValue); const newArray = [...checkboxDisplay]; newArray[n] = !checkboxDisplay[n]; // refresh available device setCheckboxDisplay(newArray); const [aSerialArray, serialBoolArray] =filterDevicesByUserId (n, deviceTypeSelected[n],item, newValue); resetNumberAndDegem(n, aSerialArray); };

ESTE ES EL SELECCIONADOR

 function ElementDeviceType(props) { const index = props.index; const item = props.item; const color = deviceTypePickerEnable[index] ? 'white' : 'gray'; return ( <View style={styles.deviceTextView}> <Text style={[styles.label1, { color: color }]}>device:</Text> <View style={styles.deviceBoxView}> <Picker mode="dropdown" enabled={deviceTypePickerEnable[index]} selectedValue={deviceTypeSelected[index]} style={styles.devicePicker} onValueChange={(newValue) => onChangeDeviceType(index, newValue,item)} > <Picker.Item label="choose device" value="" enabled={false} color={'#ddd'} itemStyle={{ color: '#ccc' }} /> {deviceTypeDisplayed[index].map((elem, i) => ( <Picker.Item label={getDeviceTestName(elem)} value={elem} key={i} /> ))} </Picker> </View> </View> ); }

ESTA ES LA FUNCIÓN onChangeDeviceType DEL SELECCIONADOR

 const onChangeDeviceType = (n, newDeviceType,item) => { console.log('onChangeDeviceType n,newDeviceType,item:', n, newDeviceType,item); if(newDeviceType != ''){ const newATyperray = [...deviceTypeSelected]; newATyperray[n] = newDeviceType; setDeviceTypeSelected(newATyperray); const [aSerialArray, serialBoolArray] =filterDevicesByUserId (n, newDeviceType,item,checkboxDisplay[n]) ; const deviceArrayS = [...deviceNumberSelected]; deviceArrayS[n] = aSerialArray[0]; // set the selected serial to the 1st available onChangeDeviceNumber(n, aSerialArray[0],item); updateAllInputs( UPDATE_TYPE.DEVICE_TYPE, newATyperray, deviceArrayS, serialBoolArray ); } };
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Puedes hacerlo con la ayuda de ganchos nativos de reacción.

Aquí hay un código de ejemplo para su referencia: https://thewebdev.info/2021/02/05/how-to-reset-to-initial-state-with-react-hooks/

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda