ptomasroos / react-native-tab-navigator

A tab bar that switches between scenes, written in JS for cross-platform support
MIT License
2.4k stars 416 forks source link

In the child component ,the navigator not work #59

Closed zhaohysjdd closed 6 years ago

zhaohysjdd commented 8 years ago

In my project , I want to use function of navigator in child component of Tabnavigator such as navigator.push.but its doest work.

`_renderTabItem(img,selectedImg, tag, childView) {

    return (           

        <TabNavigator.Item
            selected={this.state.selectedTab === tag}
            renderIcon={() => <Image style={styles.tabIcon} source={img}/>}
            renderSelectedIcon={() => <Image style={styles.tabIcon} source={selectedImg}/>}
            onPress={() => this.setState({ selectedTab: tag })}>
            {childView}
        </TabNavigator.Item>            
    );
}`

<TabNavigator hidesTabTouch={false} tabBarStyle={tabBarStyle} sceneStyle={sceneStyle}> {this._renderTabItem(HOME_NORMAL, HOME_FOCUS, HOME, <ListPage/>)} I want in use pop and push etc.error is undefined is not a function (evaluating 'this.props.nav.push({id:name})')

sbaar commented 8 years ago

This is indeed a problem, also arising with navigator.geolocation. I mitigated the problem by moving the navigator.geolocation to the same file as the tab navigator, and passing the results as props to the tabs.

ptomasroos commented 6 years ago

Will close since this issue is more than a year, feel free to a open a new if this is still a issue.