Navigation引入,需添加很多依赖,由于新版本往往对老代码不友好,建议去官网添加依赖,否则很多时候各种问题,浪费时间
官网:
https://reactnavigation.org/docs/getting-started
代码:
- import React from 'react';
- import type {Node} from 'react';
-
- import { NavigationContainer } from '@react-navigation/native';
- import { createNativeStackNavigator } from '@react-navigation/native-stack';
-
-
- import {
- SafeAreaView,
- ScrollView,
- StatusBar,
- StyleSheet,
- Text,
- TextInput,
- Button,
- useColorScheme,
- View,
- ToastAndroid,
- } from 'react-native';
-
- import {
- Colors,
- DebugInstructions,
- Header,
- LearnMoreLinks,
- ReloadInstructions,
- } from 'react-native/Libraries/NewAppScreen';
-
-
-
- const App: () => Node = () => {
- const isDarkMode = useColorScheme() ==