English 中文(简体)
React React 原生展览路由器 - 隐藏家庭屏幕上的堆叠页眉
原标题:React Native Expo Router - Hiding the Stack header on home screen
I m using expo-router in my React Native Expo app containing 2 screens, app/home.js and app/details.js. There is a Link on home.js that navigates to details.js screen. Right now both screens have the header on the top of the screen. Is there a way to disable the header only for the home.js screen? After navigation from the home screen to the details screen, the header on the details screen should still show the back arrow for the user to navigate back up to the home screen. app/_layout.js import { Stack } from "expo-router"; import { SafeAreaProvider } from "react-native-safe-area-context"; export default function Layout() { return ( ); }
最佳回答
From the expo-router docs: You can use a layout s Screen component to configure the header bar dynamically from within the route. This is good for interactions that change the UI. So in your home.js (or in any route for which you may want a custom header) you can add: null }} /> Even though you cannot disable the header per-se, you can replace it with a custom element which is null. This will visually remove the header for any route you add it to. Of course, the header on details.js will stay the same.
问题回答
Someone commented that the answer isn t clear, I will add some explanation here for those who don t google. expo-router can specify screen setup, below configures the screen under stack navigator. And by having this Stack.Screen configured for index file, you can hide the header per screen without extra workaround. This is all part of expo-router doc btw. You can find the doc at: https://reactnavigation.org/docs/stack-navigator/#header-related-options
The better option is to use headerShown: false on the options prop.




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签