[NativeBase Tabs函数onChangeTab导致应用程序冻结

问题描述 投票:2回答:1

我的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>
react-native
1个回答
2
投票

更改

this.setState({ currentTab: i })}

收件人

this.setState.bind({ currentTab: i })}
© www.soinside.com 2019 - 2024. All rights reserved.