Nativebase: Setting page prop on Tabs does nothing

Created on 14 Sep 2016  路  6Comments  路  Source: GeekyAnts/NativeBase

I want to switch active tab of Tabs component programatically, I'm passing a prop page equal to 1 to make the second tab active and it does nothing.

Most helpful comment

@phixtalk

You need to set your _tabs object in the constructor
I have this._tabs = null and than you reference the tab component

<Tabs 
ref={ t=>this._tabs = t } 
renderTabBar={() => <ScrollableTab/>}>
                           --MY TABS--
</Tabs>

Than i have an input with an onFocus

   <Input
   onFocus={()=>{this._tabs.goToPage(tabsIndex)}}<---- call the ref 
   onChangeText={this.handleText}/>

Using refs stuff seems a bit dodgy though, but it works when you need a hack

All 6 comments

@sankhadeeproy007 I have the same problem.

Will be documented soon,
this._tabs.goToPage(tabIndex); should do the needful. tabIndex is an integer denoting the Tab number.

Hello, please this._tabs.goToPage(tabindex) is not working for me.Please what am i doing wrong?

render() {
return (
Feed}>...
Trending}>

);
}

@phixtalk

You need to set your _tabs object in the constructor
I have this._tabs = null and than you reference the tab component

<Tabs 
ref={ t=>this._tabs = t } 
renderTabBar={() => <ScrollableTab/>}>
                           --MY TABS--
</Tabs>

Than i have an input with an onFocus

   <Input
   onFocus={()=>{this._tabs.goToPage(tabsIndex)}}<---- call the ref 
   onChangeText={this.handleText}/>

Using refs stuff seems a bit dodgy though, but it works when you need a hack

@phixtalk

You need to set your _tabs object in the constructor
I have this._tabs = null and than you reference the tab component

<Tabs 
ref={ t=>this._tabs = t } 
renderTabBar={() => <ScrollableTab/>}>
                           --MY TABS--
</Tabs>

Than i have an input with an onFocus

   <Input
   onFocus={()=>{this._tabs.goToPage(tabsIndex)}}<---- call the ref 
   onChangeText={this.handleText}/>

Using refs stuff seems a bit dodgy though, but it works when you need a hack

Work for me but the current tab was not highlited

@phixtalk

You need to set your _tabs object in the constructor
I have this._tabs = null and than you reference the tab component

<Tabs 
ref={ t=>this._tabs = t } 
renderTabBar={() => <ScrollableTab/>}>
                           --MY TABS--
</Tabs>

Than i have an input with an onFocus

   <Input
   onFocus={()=>{this._tabs.goToPage(tabsIndex)}}<---- call the ref 
   onChangeText={this.handleText}/>

Using refs stuff seems a bit dodgy though, but it works when you need a hack

is not work for me and no error ,its undefined
i have only 2 tabs

what do you mean "You need to set your _tabs object in the constructor"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elnygren picture elnygren  路  3Comments

sihemhssine picture sihemhssine  路  3Comments

bsiddiqui picture bsiddiqui  路  3Comments

mcpracht picture mcpracht  路  3Comments

Bundas picture Bundas  路  3Comments