▶ Passing parameters to routes
https://reactnavigation.org/docs/params/#passing-params-to-nested-navigators
// 네비게이터 이동
navigation.navigate("Stack", { screen: "Detail" })
// 네비게이터 이동 + 파라미터 전달
navigation.navigate("Stack", {
screen: "Detail",
params: { user: "jane" }
});
// Detail.js
const Detail = () => { } // 기본
const Detail = ({ route, navigation }) => {
const { user } = route.params; // "jane"
useEffect(() => {
navigation.setOptions({
title: "title"
})
}, []);
const Detail = ({ navigation: {setOptions}, route: { params: { user }} }) => {
useEffect(() => {
navigation.setOptions({
title: "title"
})
}, []);