Invariant Violation: eventType argument is required when `goBack()` React Navigation 5

Viewed 235

i am using "@react-navigation/native": "^5.9.3", and trying to use Hooks but unfortunately i am getting error Invariant Violation: eventType argument is required. when trying to pop i.e goBakc() called
Basically i have all of my screen in a single stack and i am trying to use hook in my child component let say Header.tsx which is being used in all over the project.

code for it really simple.

import { useNavigation } from "@react-navigation/native"
const { goBack } = useNavigation()

and onPress i am just calling.

onPress={() => goBack()}

error can be seen in the screensot

1 Answers

It was not due to the goBack() or navigation issue
I was using some native modules and adding/subscribing a custom event, for removing it eventEmitter.removeAllListeners() which was the cause of crash
Just replaced it with eventEmitter.removeListener('CustomeEventName', () => {})

Related