简体   繁体   English

在 react-native-tab-view 中打开模式

[英]Open modal inside react-native-tab-view

I want to show some data in Modal, I need to use modal inside of tab view我想在模态中显示一些数据,我需要在选项卡视图中使用模态

react-native-tab-view反应本机选项卡视图
react-native-modal反应本机模式

but when i add modal inside of tab view then initially modal is render every time and cannot be dismissed.但是当我在选项卡视图中添加模态时,最初模态每次都会渲染并且不能被关闭。 I already tested using modal in different way...我已经以不同的方式使用模态进行了测试......

  1. Inside of file文件内
  2. outside of file文件外
  3. Inside of Function Function内部
  4. using as a component作为组件使用

every time Modal render first and cannot be dismissed.每次 Modal 首先渲染并且不能被关闭。

The best way to achieve that is by using a Global Modal .实现这一目标的最佳方法是使用Global Modal

At first, create a folder called connected-components and create your modal as in this example首先,创建一个名为connected-components的文件夹并创建您的模态,如本例所示

Use your reducer engine to change visible value by creating two actions one to show the modal and another to hide it, You can also pass your custom data using the reducer.使用减速器引擎通过创建两个操作来更改visible值,一个是显示模式,另一个是隐藏它,您还可以使用减速器传递自定义数据。

To make it work just add your Global Modal component to your App.js and by this way you can open it from every place on your app.要使其正常工作,只需将您的Global Modal组件添加到您的App.js ,这样您就可以从应用程序的每个位置打开它。

If you have any questions just add a comment, Hope this help you through.如果您有任何问题,只需添加评论,希望这可以帮助您完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM