Close react native modal by clicking on overlay?

前端 未结 13 664
梦如初夏
梦如初夏 2020-12-23 14:27

Is it possible to close react native modal by clicking on overlay when transparent option is true? Documentation doesn\'t provide anything about it

13条回答
  •  梦毁少年i
    2020-12-23 14:54

    Here is my simple implementation:

     // Code to close your modal goes here
         // The view to drawn the background
                 true}
                    style={styles.container}
                > // The view to drawn your modal
                // Your content
                
            
        
    
    

    I use TouchableWithoutFeedback since i do not want to change the background color when clicking on it. I also added onStartShouldSetResponder on the modal view to prevent closing the modal when you click inside the view.

    I am also not using the Modal component because i done it using react-navigation.

提交回复
热议问题