Currently trying to do some routing in React Native using Expo Go. I am able to route to new pages via useRouter().push()
but when going back to a previous page, Expo Go crashes without any error messages.
Here is the source code:
// index.tsx
import { Button, Text, View } from "react-native";
import { useRouter } from "expo-router";
export default function Index() {
const router = useRouter();
return (
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
}}
>
<Text>Edit app/index.tsx to edit this screen.</Text>
<Button title="Profile" onPress={() => router.push("profile")} />
</View>
);
}
// profile.tsx
import { Button, Text, View } from "react-native";
import { useRouter } from "expo-router";
export default function Index() {
const router = useRouter();
return (
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
}}
>
<Text>Edit app/index.tsx to edit this screen.</Text>
<Button title="Profile" onPress={() => router.push("profile")} />
</View>
);
}
// _layout.tsx
import { Stack } from "expo-router";
export default function Layout() {
return <Stack />;
}
The source code was initially created by using npx create-expo-app projectName
. I am running Expo Go on an iOS device. On the web version routing appears to work so I’m lead to assume there is something wrong with using Expo Go on an iOS device but I’m not sure.
Any help would be appreciated, thanks!