[英]How to Change Header Title Component in React navigation
I am Using Product Search Component In Header Of EmptyPage, It works Fine.我在 EmptyPage 的 Header 中使用产品搜索组件,它工作正常。 Now My Req is to change the Header Title Component Dynamically, If i come From DiagnosticSearch Page I need The Header Title Component Should Be, How to change it Dynamically???
现在我的要求是动态更改 Header 标题组件,如果我来自诊断搜索页面,我需要 Header 标题组件应该是,如何动态更改它???
<Stack.Screen name='EmptyPage' component={EmptyPage} options={{ headerShown:true,headerTitle: () => <ProductSearch/>}}/>
I would do it in the EmptyPage screen component, create:我会在 EmptyPage 屏幕组件中执行此操作,创建:
export const screenOptions = navData => {
const title = navData.route ? navData.route.params : null
return {
headerTitle: title,
}
and inside the function of EmptyPage和 EmptyPage 的 function 里面
useEffect(() => {
props.navigation.setParams({ title:theUpdatedTitle })
}, [theUpdatedTitle])
now in the navigation:现在在导航中:
<Stack.Screen name='EmptyPage' component={EmptyPage} options{importedScreenOptions}/>
hope this helps you希望这对你有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.