React native 反应导航(本机):自定义标题
我发现react导航的抽屉组件不能覆盖整个应用程序。我真的很挣扎,因为我是新来的React Native,无法想出“干净的方式”来做这件事 下面是一个例子: 当你按下“切换抽屉”时,我希望它能覆盖整个应用程序,包括标题,但它只覆盖主要内容。在他们的例子中,抽屉总是只在没有内容和标题的情况下工作React native 反应导航(本机):自定义标题,react-native,react-navigation,react-navigation-drawer,React Native,React Navigation,React Navigation Drawer,我发现react导航的抽屉组件不能覆盖整个应用程序。我真的很挣扎,因为我是新来的React Native,无法想出“干净的方式”来做这件事 下面是一个例子: 当你按下“切换抽屉”时,我希望它能覆盖整个应用程序,包括标题,但它只覆盖主要内容。在他们的例子中,抽屉总是只在没有内容和标题的情况下工作 谢谢大家! 我认为您应该将标题组件移动到每个屏幕,或者使用抽屉中的堆栈创建标题我认为您应该将标题组件移动到每个屏幕,或者使用抽屉中的堆栈创建标题我认为这是一个简单的解决方案 function withH
谢谢大家! 我认为您应该将标题组件移动到每个屏幕,或者使用抽屉中的堆栈创建标题我认为您应该将标题组件移动到每个屏幕,或者使用抽屉中的堆栈创建标题我认为这是一个简单的解决方案
function withHeader(Component) {
return function(props) {
return (
<>
<Header />
<Component {...props} />
</>
)
}
}
function MyDrawer() {
return (
<Drawer.Navigator>
<Drawer.Screen name="Feed" component={withHeader(Feed)} />
<Drawer.Screen name="Notifications" component={withHeader(Notifications)} />
</Drawer.Navigator>
);
}
function Header() {
return <View style={{height: '50px', backgroundColor: 'red'}}>
<Text>My custom header!</Text>
</View>
}
export default function App() {
return (
<NavigationContainer>
<MyDrawer />
</NavigationContainer>
);
}
带标头的函数(组件){
返回功能(道具){
返回(
)
}
}
函数MyDrawer(){
返回(
);
}
函数头(){
返回
我的自定义标题!
}
导出默认函数App(){
返回(
);
}
我认为这是一个简单的解决方案
function withHeader(Component) {
return function(props) {
return (
<>
<Header />
<Component {...props} />
</>
)
}
}
function MyDrawer() {
return (
<Drawer.Navigator>
<Drawer.Screen name="Feed" component={withHeader(Feed)} />
<Drawer.Screen name="Notifications" component={withHeader(Notifications)} />
</Drawer.Navigator>
);
}
function Header() {
return <View style={{height: '50px', backgroundColor: 'red'}}>
<Text>My custom header!</Text>
</View>
}
export default function App() {
return (
<NavigationContainer>
<MyDrawer />
</NavigationContainer>
);
}
带标头的函数(组件){
返回功能(道具){
返回(
)
}
}
函数MyDrawer(){
返回(
);
}
函数头(){
返回
我的自定义标题!
}
导出默认函数App(){
返回(
);
}