我正在使用react-navigation v3,是否有选项可以使非活动的选项卡屏幕像unmountInactiveRoutes:一样在DrawerNavigator中卸载?我找不到类似于BottomTabNavigator的unmountInactiveRoutes的东西。
我在BottomTabNavigator内有两个stacknavigator,我想自动卸载它们或只重置它们。
我的导航员:
您可以使用useIsFocused挂钩解决您的问题。因此,当屏幕聚焦时,您将显示所需的屏幕,否则只需返回null。
import { useIsFocused } from '@react-navigation/native';
const isFocused = useIsFocused();
if(isFocused) return(/*your screen*/)
else if(!isFocused) return null