React-native:在堆栈导航器中动态更新标题标题 [英] React-native : Dynamically update header title in stack navigator

查看:47
本文介绍了React-native:在堆栈导航器中动态更新标题标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为标题标题(堆栈导航器)制作了一个自定义组件,它显示用户名和一些图像.在此页面上,我必须编辑用户名并成功在标题中更新它

I have made a custom component for header title(stack navigator)which shows user name along with some image. On this page I have to edit the username and on success Update it in header as well

所以我的问题是如何动态更改/更新标题?

推荐答案

这可以使用导航道具来完成.

This can be done using the navigation props.

您可以在组件中使用 this.props.navigation.state.params 来设置新属性.致电:

You can use this.props.navigation.state.params in a component to set a new property. Call:

navigation.setParams({ param: value })

请参阅有关标题的文档了解更多详情.

这篇关于React-native:在堆栈导航器中动态更新标题标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆