Поскольку я новичок в react-native
, я просто пытаюсь создать простое приложение в react-native
, которое может перемещаться.
index. js
import React from 'react';
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import 'react-native-gesture-handler';
import {NavigationContainer} from '@react-navigation/native';
import Login from './Login';
import createStackNavigator from '@react-navigation/stack/src/navigators/createStackNavigator';
const Stack = createStackNavigator();
function MyStack() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={App}
options={{title: 'Welcome'}}
/>
<Stack.Screen name="Profile" component={Login} />
</Stack.Navigator>
</NavigationContainer>
);
}
AppRegistry.registerComponent(appName, MyStack);
Теперь он дает мне ошибку:
![enter image description here](https://i.stack.imgur.com/QZxGn.png)
Если я заверну это MyStack
, это выдаст мне еще одну ошибку:
![enter image description here](https://i.stack.imgur.com/lpX5h.png)
Мой пакет. json:
"dependencies": {
"@freakycoder/react-native-helpers": "^0.1.2",
"@react-native-community/masked-view": "^0.1.6",
"@react-navigation/native": "^5.0.6",
"@react-navigation/stack": "^5.0.6",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-dynamic-vector-icons": "^0.2.1",
"react-native-gesture-handler": "^1.6.0",
"react-native-improved-text-input": "^0.0.1",
"react-native-login-screen": "^0.3.6",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.0.0-beta.8",
"react-native-spinkit": "^1.5.0",
"react-native-splash-screen": "^3.2.0",
"react-native-vector-icons": "^6.6.0"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/runtime": "^7.8.4",
"@react-native-community/eslint-config": "^0.0.7",
"babel-jest": "^25.1.0",
"eslint": "^6.8.0",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.58.0",
"react-test-renderer": "16.9.0"
},
В моем app/build.gradle
я добавил эти два:
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
Перезапущен и аннулирован кеш тоже.