onChangeTab for Tabs causing app to freeze
See original GitHub issuenode, npm, react-native, react and native-base version, expo version if used
“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”
Expected behaviour
the state should have currentTabIndex as the selected index.
Actual behaviour
app freezes
Steps to reproduce
<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>
Is the bug present in both iOS and Android or in any one of them?
both
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
NativeBase Tabs function onChangeTab causing app to freeze
the app freezes when i try the below code <Tabs tabBarPosition="bottom" initialPage={1} locked onChangeTab={({ i }) => this.
Read more >Alt + Tab and Task Bar Freezing - Microsoft Community
Recently I ran into an issue where when I open either Microsoft Apps, Windows Store Apps and the Settings on my pc it...
Read more >Fix an Android device that freezes or won't respond
Troubleshoot your phone · Open your phone's Settings app. · Near the bottom, tap System and then System update. If needed, first tap...
Read more >Chrome update on android makes the application freeze. I ...
Go to chrome://history/syncedTabs on another computer. All of your tabs should show.
Read more >How do I restart a Galaxy Tab if it appears to be frozen or not ...
How to fix your device will depend on what is causing your device to freeze or become unresponsive. The most common reason for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rubinjohny @n-sviridenko @chatdanai Use bind in setState onChangeTab={({ i }) => this.setState.bind({ currentTab: i })}
I’ve tried many ways to work around for this issue, and I found a way to improve it:
Instead use state for current tab, you should: - Use variable to store current tab - Call forceUpdate() function to make renderUI again
Example:
And in renderTab function, replace this.state to your variable to select style for tabbar: Example: