英文:
'transitionConfig' is removed in favor of the new animation APIs
问题
我正在使用React Native应用程序,控制台显示警告。
import { createStackNavigator } from 'react-navigation-stack';
import { fromRight } from 'react-navigation-transitions';
const ApplyNowNav = createStackNavigator(
{
Home,
Profile,
},
{
headerMode: 'none',
transitionConfig: () => fromRight(),
}
);
警告
createStackNavigator
中的已弃用项:
transitionConfig
已被移除,新的动画API已推出。
是否有解决此问题的方法?
英文:
I am working with a react native application, and it shows a warning in the console
import {createStackNavigator} from 'react-navigation-stack';
import {fromRight} from 'react-navigation-transitions';
const ApplyNowNav = createStackNavigator(
{
Home,
Profile,
},
{
headerMode: 'none',
transitionConfig: () => fromRight(),
}
);
> WARN Deprecation in 'createStackNavigator':
>
> transitionConfig' is removed in favor of the new animation APIs
Is there any solution to fix this issue?
答案1
得分: 20
你需要更新你的代码以使用新的动画API:https://reactnavigation.org/docs/en/stack-navigator.html#animations
从你发布的代码中,你可以将它更改为以下内容,以实现从右侧滑动的动画:
import { createStackNavigator, TransitionPresets } from 'react-navigation-stack';
const ApplyNowNav = createStackNavigator(
{
Home,
Profile,
},
{
headerMode: 'none',
defaultNavigationOptions: {
...TransitionPresets.SlideFromRightIOS,
},
}
);
英文:
You need to update your code to use to use the new Animation API: https://reactnavigation.org/docs/en/stack-navigator.html#animations
From the code you posted, you can change it to the following instead to have a slide from right animation:
import { createStackNavigator, TransitionPresets } from 'react-navigation-stack';
const ApplyNowNav = createStackNavigator(
{
Home,
Profile,
},
{
headerMode: 'none',
defaultNavigationOptions: {
...TransitionPresets.SlideFromRightIOS,
},
}
);
答案2
得分: 1
- 更新 react-navigation 并使用 creatStackNavigator 组件,而不是 StackNavigator。
- 检查当前的方法和语法,与以前的语法相比有很多变化。
我更新了代码后可以正常工作。
英文:
- Update react-navigation and use creatStackNavigator component instead of StackNavigator.
- Check current methods and syntax, there is a lot of changes compare to previous syntax.
Works for me when I updated the code
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论