Saya akan merancang navigasi Laci di proyek saya.
Saya menginstalnya dengan perintah ini:
npm install @react-navigation/drawer
Kemudian mengimpornya ke App.js
import { createDrawerNavigator } from '@react-navigation/drawer';
import { NavigationContainer } from '@react-navigation/native';
Ini adalah package.json
konten saya :
"@react-native-community/masked-view": "^0.1.6",
"@react-navigation/drawer": "^5.0.0",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-gesture-handler": "^1.5.6",
"react-native-reanimated": "^1.7.0",
"react-native-screens": "^2.0.0-beta.1",
"react-native-view-shot": "^3.0.2",
"react-navigation": "^4.1.1",
"react-navigation-stack": "^2.1.0",
Ini adalah App.js
konten saya :
const App = () => {
const Drawer = createDrawerNavigator();
return (
<View style={styles.container}>
<NavigationContainer>
<Drawer.Navigator initialRouteName="login">
<Drawer.Screen name="login" component={Login} />
<Drawer.Screen name="second" component={SecondPage} />
</Drawer.Navigator>
</NavigationContainer>
</View>
)
};
Saya harus mengatakan bahwa saya sudah membuat Login
dan SecondPage
komponen dan menyatakannya dalam file bernamaroot.js
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';
import { Login, Header, SecondPage, Footer, ThirdPage } from './components/index';
const AppNavigator = createStackNavigator({
login: { screen: Login },
header: { screen: Header },
second: { screen: SecondPage },
footer: { screen: Footer },
third: { screen: ThirdPage }
}, {
initialRouteName: 'login',
headerMode: 'none',
mode: 'modal',
}, {});
export default createAppContainer(AppNavigator);
Tapi saya mendapatkan kesalahan (layar berikut).
Bagaimana saya bisa memperbaikinya?
index.js
export * from './login';
export * from './header';
export * from './secondpage';
export * from './footer';
export * from './thirdpage';