Come respingere il vista modale toccando schermo nel Reagire Naitve, la componente RN modale sembra non forniscono l'APICome respingere modale toccando schermo nel ReactNative
5
A
risposta
21
È possibile utilizzare un componente TouchableWithoutFeedback all'interno del componente modale una proprietà onPress che chiude il modal.
<Modal visible={booleanThatHandlesModalVisibility}>
<TouchableWithoutFeedback onPress={() => funcToHideModal()}>
<View>
...
</View>
</TouchableWithoutFeedback>
</Modal>
Se si desidera una zona del modal che non nasconde il modal sulla stampa è possibile aggiungere un altro TouchableWithoutFeedback senza una proprietà onPress per catturare l'evento prima che il primo uno come questo:
<Modal visible={booleanThatHandlesModalVisibility}>
<TouchableWithoutFeedback onPress={() => funcToHideModal()}>
<View>
<TouchableWithoutFeedback>
<View>...</View>
</TouchableWithoutFeedback>
</View>
</TouchableWithoutFeedback>
</Modal>
Ho risolto il mio problema con questa idea, anche se vedo che '' 'TouchableOpacity''' non ha' '' onPressOut''', e ho dovuto usare '' 'TouchableOpacity''' con un'azione vuota invece di' ' 'TouchableWithoutFeedback''' – samthui7