0

Function :

  async function ridirect(APIresponse) {
const { navigate } = this.props.navigation;
if(APIresponse.success == true){
  navigate('HomeBottomBar')

}
}

this function was getting error.

3
  • What was the error message? What does your navigation config look like? Commented Apr 23, 2021 at 1:59
  • [TypeError: undefined is not an object (evaluating 'this.props.navigation') Commented Apr 23, 2021 at 2:12
  • This might help you stackoverflow.com/questions/45226391/… Commented Apr 24, 2021 at 6:20

1 Answer 1

0

It's you're not passing the navigation prop to the component. You could use Navigation Context to pass navigation to the function.

E.g.:

import { NavigationContext } from '@react-navigation/native';

async function ridirect(APIresponse) {
  const contextType = NavigationContext;;
  if(APIresponse.success == true){
    navigate('HomeBottomBar')
  }
}
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.