【问题标题】:Attempted import error: 'MaskedViewIOS' is not exported from 'react-native'尝试导入错误:“MaskedViewIOS”未从“react-native”导出
【发布时间】:2019-12-30 04:12:47
【问题描述】:

我想学习 React Native。我想构建一个 web 应用程序和一个 android 应用程序。我想在我的应用程序的屏幕之间导航。所以我这样做了:

npx create-react-app my-app
cd my-app
npm install react-native-web

然后我将index.js 更新为如下所示:

import React from 'react';
import App from './App';
import { AppRegistry } from 'react-native';
AppRegistry.registerComponent('App', () => App);
AppRegistry.runApplication('App', { rootTag: document.getElementById('root') });

我将App.js 更新为如下所示:

import React from 'react';
import {createAppContainer} from 'react-navigation';
import {createStackNavigator} from 'react-navigation-stack';
const MainNavigator = createStackNavigator({Home: {screen: function(props){return null}}});
const App = createAppContainer(MainNavigator);
export default App;

当我运行npm start 命令时,我得到了错误

./node_modules/react-navigation-stack/lib/module/views/Header/Header.js
Attempted import error: 'MaskedViewIOS' is not exported from 'react-native'.

有人知道如何解决这个问题吗?

【问题讨论】:

    标签: react-native react-navigation react-native-web


    【解决方案1】:

    看起来这是react-navigation-stack v1 中的一个问题,最新版本为react-native-web,但我认为不会解决。

    问题是 MaskedViewIOS 已移至 react-native-community issue #132:

    https://github.com/react-native-community/react-native-masked-view

    【讨论】:

      【解决方案2】:

      更新到 react-navigation-stack v2

      【讨论】:

        猜你喜欢
        • 2019-06-06
        • 2020-12-06
        • 2021-02-13
        • 1970-01-01
        • 1970-01-01
        • 2019-10-24
        • 2021-10-20
        • 2019-12-19
        • 2023-03-11
        相关资源
        最近更新 更多