0

So i making a react app and there is a screen where i have a button on the right side of the header. The problem is that it crashes when clicked. Here is the code inside the react component (placed right above the constructor method):

static navigationOptions = {
    headerRight: <Ionicons style={{marginRight: 15}} name={prefix + 'power'}
                    color={colors.app_secondary_color} size={30} onPress={() => this.signout()}/>
  }

And here is the error:

_this3.signout is not a function. (In '_this3.signout()', '_this3.signout' is undefined)

onPress
    ProfileView.js:25:80

i'm thinking the this reference doesn't reach that far?

1 Answer 1

1

There is no this.signout because navigationOptions is static. You can achieve what you want by extracting the button into a different component and connecting it to the redux store, then dispatch a signout action onPress

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

1 Comment

thanks! i am trying to use firebase but i'll gladly add redux to my native app logic.

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.