我想在drawer
元素为clicked
. 换句话说,我正在寻找一个与 property 等价的抽屉tabPress
。我尝试将我的回调添加到属性focus
。但是,只要相关堆栈中的“任何屏幕”处于“焦点”状态,就会执行此回调。
我希望代码只有在用户“点击” “抽屉项目”时才会被删除。这是可能吗?
import { createDrawerNavigator } from "@react-navigation/drawer";
const MyNav = createDrawerNavigator();
<MyNav.Navigator>
<MyNav.Screen name="abc" component={abcStack}
listeners={ ({ navigation, route }) => ({
// This is executed whenever any screen in the stack is accessed. This does NOT satisfy my requirements.
focus: (e) => {
console.log("We are in focus");
},
// Is there something like "tabPress" for Drawer stacks?
tabPress: (e) => {
console.log("We are on tabPress");
},
})}
/>
</MyNav.Navigator>
这个问题与 React-Navigation 版本 6 有关。