‘transitionConfig’ 已被新的动画 API 替代。

huangapple go评论98阅读模式
英文:

'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

  1. 更新 react-navigation 并使用 creatStackNavigator 组件,而不是 StackNavigator。
  2. 检查当前的方法和语法,与以前的语法相比有很多变化。

我更新了代码后可以正常工作。

英文:
  1. Update react-navigation and use creatStackNavigator component instead of StackNavigator.
  2. Check current methods and syntax, there is a lot of changes compare to previous syntax.

Works for me when I updated the code

huangapple
  • 本文由 发表于 2020年1月6日 19:56:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/59611691.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定