'How to show back button using Expo and React Router v6 NativeRouter
I am new to React Native and I am using Expo to create a simple app with two routes. I am using the Link element to navigate to another route (and that works) but no Back button appears. What am I doing wrong? Can someone advise or point me to documentation or an example on how to do this in React Native?
export default function App() {
return(
<SafeAreaView>
<NativeRouter>
<Routes>
<Route path="/" element={<Home />}> </Route>
<Route path="home/:id" element={<Details />}> </Route>
<Route path="*" element={<Text>There's nothing here!</Text>} />
</Routes>
</NativeRouter>
</SafeAreaView>
);
}
export default function Home() {
let details = getDetails();
return (
<View>
{details.map((d) =>
<Link to={`/home/${d.id}`} key={d.id}>
<Text>{d.title}</Text>
</Link>
)}
</View>
);
}
"dependencies": {
"@react-navigation/native": "^6.0.8",
"@react-navigation/native-stack": "^6.5.0",
"expo": "~44.0.0",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "~3.10.1",
"react-native-svg": "12.1.1",
"react-native-web": "0.17.1",
"react-router-native": "^6.2.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@types/react": "~17.0.21",
"@types/react-native": "~0.64.12",
"typescript": "~4.3.5"
},
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
