[英]Invariant Violation: eventType argument is required when `goBack()` React Navigation 5
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.
我正在使用
"@react-navigation/native": "^5.9.3",
并尝试使用 Hooks,但不幸的是我收到错误Invariant Violation: eventType argument is required.
when trying to pop ie goBakc()
called当试图弹出即
goBakc()
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.基本上我的所有屏幕都放在一个
single stack
中,我试图在我的子组件中使用钩子,比如说Header.tsx
,它正在整个项目中使用。
code for it really simple.它的代码非常简单。
import { useNavigation } from "@react-navigation/native"
const { goBack } = useNavigation()
and onPress i am just calling.和 onPress 我只是打电话。
onPress={() => goBack()}
onPress={() => goBack()}
It was not due to the goBack()
or navigation issue这不是由于
goBack()
或导航问题
I was using some native modules and adding/subscribing a custom event, for removing it eventEmitter.removeAllListeners()
which was the cause of crash我正在使用一些本机模块并添加/订阅自定义事件,以删除它
eventEmitter.removeAllListeners()
这是导致崩溃的原因
Just replaced it with eventEmitter.removeListener('CustomeEventName', () => {})
只需将其替换为
eventEmitter.removeListener('CustomeEventName', () => {})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.