How to get state from parent in react native? -
i have tabnavigator :
<tabnavigator> <tabnavigator.item selected={this.state.selectedtab === 'home'} title="home" rendericon={() => <image source={icon1}/>} renderselectedicon={() => <image source={require('./img/slider-left.png')}/>} onpress={() => this.setstate({ selectedtab: 'home' })} > <mainnav selectedtab={this.state.selectedtab} getselectedtab = {() => this.state.selectedtab}/> </tabnavigator.item> <tabnavigator.item selected={this.state.selectedtab === 'profile'} title="profile" rendericon={() => <image source={icon1}/>} renderselectedicon={() => <image source={icon1}/>} onpress={() => this.setstate({ selectedtab: 'profile' })} > <topicnav selectedtab={this.state.selectedtab} /*this not work*//> </tabnavigator.item> </tabnavigator>
and in mainnav , topicnav (in seperated files) both have navigator stack, , backandroid process physical events, 2 backandroid can event @ same time, this:
backandroid.addeventlistener('hardwarebackpress', () => { if (_navigator.getcurrentroutes().length === 1 ) { return false; } _navigator.pop(); return true; });
i need know current shown tab, , respond shown one. how can parent state selectedtab when changes? thanks.
Comments
Post a Comment