1

I have a problem, in React-Native.

<Button title="Save" onPress = {() => navigation.navigate('Save' , { image })}/>
    {image && <Image source = {{uri: image}} style= {{flex: 1}}/>}
    </View>
  );
}

I got an error:

navigation.navigate is not a function. (In 'navigation.navigate('Save', {image: image})', 'navigation.navigate' is undefined)
1
  • Give more context. You probably missed to pass navigation prop to the component where you use Button Commented Jan 16, 2021 at 9:24

1 Answer 1

2

Give your component a navigation prop like shown below.

Also make sure that it's added in Navigation stack.

function YourComponentName({navigation}){
return (
<View>
<Button title="Save" onPress = {() => navigation.navigate('Save' , { image })}/>
    {image && <Image source = {{uri: image}} style= {{flex: 1}}/>}
    </View>
  );
}

You can also use useNavigation hooks

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.