0

Im trying to use react-navigation custom header like this

static navigationOptions = {
    header: <EventHeader
        subscribestatus={this.props.navigation.getParam('status')}
        confirmation={this.props.navigation.getParam('confirmation')}
        deleteSubscribe={this.deleteSubscribe}
        joinEvent={this.joinEvent}
        onPress={()=>this.props.navigation.goBack()}
        eventname={this.props.navigation.getParam('title')}
    />
};

This header getting params previous screen as you see but im getting undefined is not an object (evaluating 'this.props.navigation')

What i am doing wrong and how can i solve this ?

1 Answer 1

1

I hope you found the solution, but for other people which could come here :

navigationOptions can be a function which will pass navigator as first argument and can return an object. So you could write it like so :

static navigationOptions = (navigator) => { return { header: ( <EventHeader subscribestatus={navigator.navigation.getParam('status')} confirmation={navigator.navigation.getParam('confirmation')} //deleteSubscribe={this.deleteSubscribe} //joinEvent={this.joinEvent} onPress={()=>navigator.navigation.goBack()} eventname={navigator.navigation.getParam('title')} /> ) } } Unfortunately, you will not have access to this.deleteSubscribe or this.joinEvent

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.