NativeBase Tabs功能onChangeTab导致应用程序冻结

时间:2018-10-12 11:29:22

标签: react-native

package.json中的我的版本 “ expo”:“ ^ 30.0.1” “ native-base”:“ ^ 2.8.1” “ react”:“ 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>

1 个答案:

答案 0 :(得分:1)

更改

this.setState({ currentTab: i })}

收件人

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