Auryn
Auryn

Reputation: 1176

onRightButtonPress React Native undefined is not an object NavigatorIOS

Here There

I have a problem with my React Native code, i am new in React programming, so cannot read the errors correct :-(
Hopefully someone can help

export default class NavigationBar extends Component {

_handleNavigationRequest = () => {
    this.refs.nav.push({
        component: Settings,
        title: 'Genius',
        passProps: { myProp: 'genius' },
    });
}



render() {
    return (
        <NavigatorIOS barTintColor='#50C26B' titleTextColor='#fff' tintColor='#fff'
            initialRoute={{
                component: Genius,
                title: 'Happy Genius',
                rightButtonTitle: 'Add',
                onRightButtonPress: () => this._handleNavigationRequest(),
            }}
            style={style.navBarStyle}
        />
    );
  }
}

Got the error: undefined is noch an object (evaluating 'this.refs.nav.push') enter image description here

Upvotes: 0

Views: 47

Answers (1)

Gabriel Diez
Gabriel Diez

Reputation: 1693

You forgot the ref parameter in your NavigatorIOS

render() {
    return (
        <NavigatorIOS ref='nav' 
            barTintColor='#50C26B' titleTextColor='#fff' tintColor='#fff'
            initialRoute={{
                component: Genius,
                title: 'Happy Genius',
                rightButtonTitle: 'Add',
                onRightButtonPress: () => this._handleNavigationRequest(),
            }}
            style={style.navBarStyle}
        />
    );
  }

Upvotes: 1

Related Questions