React native SwitchNavigator中的屏幕在导航时闪烁
在我的react本机应用程序中,我有一个开关导航器,可以在身份验证堆栈和应用程序堆栈之间导航:React native SwitchNavigator中的屏幕在导航时闪烁,react-native,react-navigation,React Native,React Navigation,在我的react本机应用程序中,我有一个开关导航器,可以在身份验证堆栈和应用程序堆栈之间导航: const AppNavigator = createSwitchNavigator( { App: AppStack, Auth: AuthStack }, { initialRouteName: "Auth", } ); 但是,当我从AuthStack转到AppStack时,它会闪烁,屏幕会向上移动。如何防止这种行为添加平滑过渡。我可以使用animated
const AppNavigator = createSwitchNavigator(
{
App: AppStack,
Auth: AuthStack
},
{
initialRouteName: "Auth",
}
);
但是,当我从AuthStack转到AppStack时,它会闪烁,屏幕会向上移动。如何防止这种行为添加平滑过渡。我可以使用animatedswitchnavigator而不是普通switchnavigator并添加过渡来解决此问题:
import createAnimatedSwitchNavigator from 'react-navigation-animated-switch';
import { Transition } from 'react-native-reanimated';
const AppNavigator = createAnimatedSwitchNavigator(
{
App: AppStack,
Auth: AuthStack
},
{
initialRouteName: "Auth",
transition: (
<Transition.Together>
<Transition.Out
type="slide-bottom"
durationMs={400}
interpolation="easeIn"
/>
<Transition.In type="fade" durationMs={500} />
</Transition.Together>
),
}
);
从“react navigation AnimatedSwitchNavigator”导入createAnimatedSwitchNavigator;
从“react native reanimated”导入{Transition};
const AppNavigator=createAnimatedSwitchNavigator(
{
应用程序:AppStack,
Auth:AuthStack
},
{
initialRouteName:“Auth”,
过渡:(
),
}
);
此处提供的文档:这是否仅发生在交换机上,还是也发生在堆栈上?这仅发生在交换机导航器上。作为参考,react navigation的当前版本(5)是管理此类转换的一种非常干净和强大的方法: