带有反应导航的 React Native 中的模态窗口 [英] Modal window in React Native with react-navigation

查看:35
本文介绍了带有反应导航的 React Native 中的模态窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 React Native 中使用 react-navigation,我想在启动时确定用户是否登录,如果他/她已经登录,我想打开一个模态窗口(全屏).

如何做到最好?我在 react-navigation 文档中找不到任何有条件显示屏幕的内容.

解决方案

看,你需要改变 Navigation 的 mode.

const RootStack = StackNavigator({主要的: {屏幕:主堆栈,},我的模态:{屏幕:模态屏幕,},},{模式:'模态',headerMode: '无',});

您可以

参考文献:

I am using react-navigation in React Native and I want, on startup, to determine if the user is logged in, and if he/she is already logged in, I want to open a modal window (full screen).

How is this best done? I cannot find anything in the react-navigation docs where a screen is conditionally shown.

解决方案

Look, you needs to change the mode from Navigation.

const RootStack = StackNavigator(
  {
    Main: {
      screen: MainStack,
    },
    MyModal: {
      screen: ModalScreen,
    },
  },
  {
    mode: 'modal',
    headerMode: 'none',
  }
);

You can run this code here

Screenshots:

References:

这篇关于带有反应导航的 React Native 中的模态窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆