我想学习本地反应。我想构建一个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'.
有人知道如何解决此问题吗?
答案 0 :(得分:1)
在react-navigation-stack
v1中,最新版本的react-native-web
似乎是一个问题,但我认为不会得到解决。
问题是MaskedViewIOS已移至react-native-community issue #132:
https://github.com/react-native-community/react-native-masked-view
答案 1 :(得分:1)
更新为react-navigation-stack v2