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 -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -