navigation_ReactNative

miin·2023년 11월 22일
0

ReactNative

목록 보기
7/10
post-thumbnail
  • 주로 화면을 이동할때 사용됨
  • App에서 <NavigationContainer>을 감싸줘야 사용 가능하다

페이지 이동할때

  const navigation = useNavigation();
	navigation.navigate('HomeScreen');

props 넘겨줄 때

navigation.navigate('Profile', { user: 'jane' });
//받을 스크린
  const {params} = useRoute();

screen이 중첩되어 있는 상황에서 사용

navigation.navigate('Profile', {
  screen: 'Profile',
  params: { user: 'jane' },
});
//받을 스크린
  const {params} = useRoute();

type

type RootStackParamList = {
    Home: undefined;
    Detail : {
        id: number;
    };
};
const Stack = createNativeStackNavigator<RootStackParamList>();

navigationRef
common
type

0개의 댓글