【问题标题】:NativeBase Tabs function onChangeTab causing app to freezeNativeBase Tabs 函数 onChangeTab 导致应用程序冻结
【发布时间】:2019-03-17 15:06:52
【问题描述】:

我的 package.json 版本 “世博会”:“^30.0.1” “本地基础”:“^2.8.1” “反应”:“16.3.1”, "react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz"

当我尝试以下代码时应用程序冻结

<Tabs tabBarPosition="bottom" initialPage={1} locked onChangeTab={({ i }) => this.setState({ currentTab: i })}>
    <Tab heading={<TabHeading>
                <Icon name="bell" type='SimpleLineIcons' style={{fontSize:22}} />
                <Text style={{color:(this.state.header == 'Snapshot'?Colors.themeBlue:'black')}}>Snapshot</Text>
        </TabHeading>} 
    >
        <Text> tab 1</Text>
    </Tab>
    <Tab heading={<TabHeading>
                <Icon name="compass" type="SimpleLineIcons" style={{fontSize:22}} />
                <Text style={{color:(this.state.header == 'Discover'?Colors.themeBlue:'black')}}>Discover</Text>
            </TabHeading>} style={{backgroundColor:'#e8e8e8'}}
    >
        <Text> tab 2</Text>
    </Tab>
</Tabs>

【问题讨论】:

    标签: react-native


    【解决方案1】:

    改变

    this.setState({ currentTab: i })}
    

    this.setState.bind({ currentTab: i })}
    

    【讨论】:

      猜你喜欢
      • 2017-09-16
      • 1970-01-01
      • 2015-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-25
      • 1970-01-01
      相关资源
      最近更新 更多