Created
September 5, 2021 16:52
-
-
Save YajanaRao/c9ef6b956a1633ded05551e6eeb76218 to your computer and use it in GitHub Desktop.
App.js for react navigation sticky header
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import { NavigationContainer } from "@react-navigation/native"; | |
import { useTheme } from "react-native-paper"; | |
import { Provider as PaperProvider } from "react-native-paper"; | |
import { createNativeStackNavigator } from "@react-navigation/native-stack"; | |
import SearchScreen from "./Search"; | |
const Stack = createNativeStackNavigator(); | |
const App = () => { | |
const theme = useTheme(); | |
const { colors } = theme; | |
return ( | |
<PaperProvider> | |
<NavigationContainer> | |
<Stack.Navigator | |
headerMode="screen" | |
screenOptions={{ | |
headerStyle: { | |
backgroundColor: colors.surface, | |
}, | |
headerTintColor: colors.text, | |
headerTitleAlign: "center", | |
safeAreaInsets: { top: 0, bottom: 0 }, | |
}} | |
> | |
<Stack.Screen name="Search" component={SearchScreen} /> | |
</Stack.Navigator> | |
</NavigationContainer> | |
</PaperProvider> | |
); | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment