从 'react-navigation-stack' 导入 { CardStyleInterpolators } 无效

import { CardStyleInterpolators } from 'react-navigation-stack' is not working

我正在使用 react-navigation 4.0.10 和 react-navigation-stack 1.10.3 并尝试实现 CardStyleInterpolations android。根据文档 https://reactnavigation.org/docs/4.x/stack-navigator 要实现这个我必须做这样的事情

import { CardStyleInterpolators } from 'react-navigation-stack';

// ...

static navigationOptions = {
  title: 'Profile',
  cardStyleInterpolator: CardStyleInterpolators.forFadeFromBottomAndroid,
}

我正在用这样的功能组件实现它

Login.navigationOptions = () => {
  return {
    cardStyleInterpolator: CardStyleInterpolators.forFadeFromBottomAndroid,
  };
};

因为静态导航选项适用于 class 组件。

这看起来很简单,但在 undefined.object 评估 CardStyleInterpolators.forFadeFromBottomAndroid 时抛出了一个错误,我想这与不正确的导入有关。任何人都知道如何正确实施它。

我在 Whosebug 找到了答案。com/questions/48018666/...。您只需将答案中的导入更改为从 'react-navigation-stack/src/views/StackView/StackViewStyleInterpolator' 导入 CardStackStyleInterpolator;对于 v4