javascript - Close react native modal by clicking on overlay? -


is possible close react native modal clicking on overlay when transparent option true? documentation doesn't provide it. possible?

if understood correctly, want close modal when user clicks outside of it, right ?

if yes, searched time ago , solution remember 1 (which 1 i've been using far):

render() {    if (!this.state.modalvisible)     return null   return (      <view>         <modal            animationtype="fade"           transparent={true}           visible={this.state.modalvisible}           onrequestclose={() => {this.setmodalvisible(false)}}         >           <touchableopacity              style={styles.container}              activeopacity={1}              onpressout={() => {this.setmodalvisible(false)}}           >             <scrollview                directionallockenabled={true}                contentcontainerstyle={styles.scrollmodal}             >               <touchablewithoutfeedback>                 <view style={styles.modalcontainer}>                   // here put content of modal.                 </view>               </touchablewithoutfeedback>             </scrollview>           </touchableopacity>            </modal>       </view>   ) }   // on setmodalvisible(), need when closing or opening modal. setmodalvisible(visible) {     this.setstate({         modalvisible: visible,     }) } 

explanation

this using touchableopacity in whole screen when user clicks close modal. touchablewithoutfeedback avoid touchableopacity work inside of modal.

if have better solution, please share here.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -