react-navigation dynamic header doesn't work?

让人想犯罪 __ 提交于 2019-12-05 21:44:48
Meysam Izadmehr

You are using docs for a version newer than the version you have installed (similar issue on githib). It's about difference between npm and github versions. Documents are for the github version, which is newer, but you installed react-navigation from npm.

The problem is you can't use navigationOptions as a function right now. When you do that it can't find navigationOptions, so there won't be a header. Use instead this:

static navigationOptions = {
  title: (navigation) => (`Chat with ${navigation.state.params.user}`),
};

When title exist, previous page title won't be shown left of the header.

Or update your package.json, so you can use the version of react-navigation docs:

"react-navigation": "git+https://github.com/react-community/react-navigation.git#7165efc",
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!