haju__log

#탭 화면 구현 예제 코드 본문

카테고리 없음

#탭 화면 구현 예제 코드

haju 2021. 5. 25. 18:38

import React from 'react';

 

import {

   StyleSheet,

   Text,

   View,

   StatusBar,

   Button,

from 'react-native';

import {NavigationContainerfrom '@react-navigation/native';

 

import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';

 

function HomeScreen() {

  return (

    <View style={flex: 1justifyContent: 'center'alignItems: 'center' }}>

      <Text>Home!</Text>

    </View>

  );

}

 

function SettingsScreen() {

  return (

    <View style={flex: 1justifyContent: 'center'alignItems: 'center' }}>

      <Text>Settings!</Text>

    </View>

  );

}

 

const Tab = createBottomTabNavigator();

 

export default function App() {

  return (

    <NavigationContainer>

      <Tab.Navigator>

        <Tab.Screen name="Home" component={HomeScreen} />

        <Tab.Screen name="Settings" component={SettingsScreen} />

      </Tab.Navigator>

    </NavigationContainer>

  );

}