본문으로 건너뛰기

파라미터 다루기

파라미터 타입 선언

먼저, 라우팅 경로에 대한 파라미터를 아래와 같이 정의해요.

export type RootStackParamList {
main: undefined;
postDetail: {
id: number;
}
}

해당 경로로 이동

useNavigation() 함수를 이용해 해당 스택경로로 이동할 수 있어요.

const navigator = useNavigation<StackNavigationProp<RootStackParamList>>();

navigator.navigate('main', {});