LayoutAnimation.Types 有哪些可用选项

What are the available options for LayoutAnimation.Types

我有一个来自 here 的自定义布局动画。

var CustomLayoutAnimation = {
    duration: 200,
    create: {
      type: LayoutAnimation.Types.linear,
      property: LayoutAnimation.Properties.opacity,
    },
    update: {
      type: LayoutAnimation.Types.curveEaseInEaseOut,
    },
  };

当 运行 代码时,我收到以下警告

Warning: Failed config type: The config config.update.type is marked as required in LayoutAnimation.configureNext, but its value is undefined.

该代码有一个 update.type 条目,但警告说它未定义。我猜自编写要点以来,允许的值已经更新。 我试图找出可用的允许条目列表,但它们未在 React Native LayoutAnimation documentation 中列出。

我想知道:

每当我 运行 遇到这样的问题时,我都会查看源代码。 Here's the file for LayoutAnimation.js from the react-native source code。基于此,我在第 25 行看到一个 TypesEnum const 声明,如下所示:

const TypesEnum = {
  spring: true,
  linear: true,
  easeInEaseOut: true,
  easeIn: true,
  easeOut: true,
  keyboard: true,
};

我怀疑这就是您犯错的原因 - curveEaseInEaseOut 不是受支持的类型。从上面的列表中选择一个,我认为你应该可以开始了。希望这对您有所帮助!