Close react native modal by clicking on overlay?

前端 未结 13 679
梦如初夏
梦如初夏 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条回答
  •  鱼传尺愫
    2020-12-23 14:47

    If you are using store solution like mobx or redux, you can simply solve with the flag on store.

    Below is the parent's code,

           {
              uiControlStore.dialogVisible = false;
            }}
          >
             {
                if (!uiControlStore.childClicked) uiControlStore.dialogVisible = false;
                uiControlStore.childClicked= false;
              }}
            >
              
            
          
    

    and below is child's code. (using mobx)

    const YourCustomDialog: React.FC = observer(() => {
      const { uiControlStore } = useStores();
    
      return (
         {
            uiControlStore.childClicked= true;
          }}
        >
        ...
      )
    }
    
    

提交回复
热议问题