After I click on on the button “Again” within the header or on the button “go house” within the particulars web page my app shut. So Why? However with the assistance of swipe I can return again.
app.jsx file – solely navigation
// Screens
import MainNavigation from "./src/routes/MainNavigation";
export default operate App() {
return (
<MainNavigation />
);
}
Navigation is like in documentation
MainNavigation.tsx
// Navigation
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
// Screens
import HomeScreen from "../screens/HomeScreen/HomeScreen";
import TodoDetailsScreen from "../screens/TodoDetailsScreen/TodoDetailsScreen";
import { Button } from "react-native";
// Hold the splash display seen whereas we fetch sources
const Stack = createNativeStackNavigator();
const MainNavigation = () => {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Dwelling">
<Stack.Display screen identify="Dwelling" element={HomeScreen} />
<Stack.Display screen
identify="Particulars"
element={TodoDetailsScreen}
choices={
{
// headerBackVisible: false,
}
}
/>
</Stack.Navigator>
</NavigationContainer>
);
};
export default MainNavigation;
HomeScreen.tsx – simply easy scrin with one redirection
import { Button, SafeAreaView, Textual content, View } from "react-native";
import { NavigationProp, RouteProp } from "@react-navigation/native";
const HomeScreen = ({
navigation,
}: {
navigation: NavigationProp<any, any>;
}) => {
return (
<SafeAreaView>
<Textual content>Dwelling display</Textual content>
<Button
onPress={() => {
navigation.navigate("Particulars", { _id: "123" });
}}
title="go to particulars TODO"
/>
</SafeAreaView>
);
};
export default HomeScreen;
TodoDetailsScreen.tsx – easy display
import { NavigationProp, RouteProp } from "@react-navigation/native";
import { Button, Textual content, View } from "react-native";
const TodoDetailsScreen = ({
navigation,
route,
}: {
route: RouteProp<any, any>;
navigation: NavigationProp<any, any>;
}) => {
const { _id } = route.params;
console.log("_id", _id);
return (
<View>
<Textual content>TodoDetailsScreen</Textual content>
<Button
onPress={() => {
navigation.navigate("Dwelling");
}}
title="go house"
/>
</View>
);
};
package deal.json
{
"identify": "reactnative-ts",
"model": "1.0.0",
"primary": "expo/AppEntry.js",
"scripts": {
"begin": "expo begin",
"android": "expo begin --android",
"ios": "expo begin --ios",
"net": "expo begin --web"
},
"dependencies": {
"@react-navigation/native": "^6.1.17",
"@react-navigation/native-stack": "^6.9.26",
"expo": "~51.0.2",
"expo-font": "^12.0.4",
"expo-splash-screen": "^0.27.4",
"expo-status-bar": "~1.12.1",
"react": "18.2.0",
"react-native": "0.74.1",
"react-native-safe-area-context": "^4.10.1",
"react-native-screens": "^3.31.1"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@varieties/react": "~18.2.45",
"typescript": "^5.1.3"
},
"non-public": true
}