question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onChangeTab for Tabs causing app to freeze

See original GitHub issue

node, 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
suvenduchhatoicommented, Dec 19, 2018

@rubinjohny @n-sviridenko @chatdanai Use bind in setState onChangeTab={({ i }) => this.setState.bind({ currentTab: i })}

0reactions
NXAN2901commented, Dec 17, 2019

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:

onChangeTab = ({ i }) => {
    this.selectedTab = i;
    this.forceUpdate();
 }

And in renderTab function, replace this.state to your variable to select style for tabbar: Example:

renderTabHeading = (index) {
const isTabSelected = this.selectedTab === index;
...
}
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found