Dynamically hide/show header in react-native

末鹿安然 提交于 2019-12-06 03:20:27
Karan Bhutwala

Got it working:

Don't know why it is so but passing undefined to header will show default header and null will hide the header.

I am doing something like this:

static navigationOptions = ({ navigation }) => ({
    header: navigation.state.params ? navigation.state.params.header : undefined
});

and on state change;

this.props.navigation.setParams({ 
        header: null 
});
Chiamaka Nwolisa

According to the docs, setting the header to null hides the header. Go about it like this

this.props.navigation.setParams({
  header: this.state.header ? whatever-you-want : null
})
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!