反应本地渲染主组件中的另一个组件 [英] react native render another component in main

查看:79
本文介绍了反应本地渲染主组件中的另一个组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在主组件中渲染另一个组件,这样用户就不会再面对白色屏幕了! 我从反应导航中使用TabNavigator,并且当我想在选项卡之间切换时,我面对白色屏幕一秒钟(似乎需要一秒钟才能呈现). 我正在考虑在第一个选项卡中显示第二个选项卡,以便获得更好的用户体验! P.s. :我的组件在单独的文件中!

i want to render another component in the main component so user won't face a white screen for a second! i'm using TabNavigator from react-navigation and when i want to switch between tabs, i face a white screen for a second (seems it need a second to render). i was thinking of rendering the second tab in the first so i can have a better user experience! P.s. : my components are in separate files!

主要

export default class AdCalc extends React.Component {
  render() {
    return (
      <View>
        <Text>
          TEST
        </Text>
      </View>
    );
  }
}

和我的孩子

export default class Child extends React.Component {
  render() {
    return (
      <View>
        <Text>
          This is child!
        </Text>
      </View>
    );
  }
}

提前谢谢!

thanks in advance!

推荐答案

您可以使用react-navigation TabNavigatorConfig的惰性道具.传递lazy = {false},以便您的视图可以在初始开始时加载.然后您将不会看到这样的屏幕.

You can use react-navigation TabNavigatorConfig's lazy prop. Pass lazy={false} so that your views may load at initial start. Then you will not see such a screen.

这篇关于反应本地渲染主组件中的另一个组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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