未知命名模块:'react/lib/NativeMethodsMixin'

Unknown named module: 'react/lib/NativeMethodsMixin'

我创建了一个新的 React Native 项目并在项目中安装了@shoutem/ui,并将 Shoutem UI 的示例组件包含到 React Native 应用程序中。

import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import { Examples } from '@shoutem/ui';

class HelloWorld extends Component {
  render() {
    return (
      <Examples />
    );
  }
}

AppRegistry.registerComponent('HelloWorld', () => HelloWorld);

但是当我 运行 启动项目时,出现 "Unknown named module: 'react/lib/NativeMethodsMixin'" 错误。

错误似乎在 @shoutem/animation 模块内,在 Parallax.js 文件中:https://github.com/shoutem/animation/blob/develop/Parallax.js NativeMethodsMixin 未从 react 正确导入:

如果你改变这个: import NativeMethodsMixin from 'react/lib/NativeMethodsMixin'; 对此:import NativeMethodsMixin from 'react'; 您的应用应该可以运行。

我会在 @shoutem/animation 项目上提交 Github 问题,或者检查 NativeMethodsMixin 的导入方式是否特定于 react 的旧版本,然后在您的应用中使用该版本。

希望对您有所帮助。

v0.8.9 release of @shoutem/animation 起已修复。