Skip to content

Commit b532f8c

Browse files
koenpuntgrabbou
authored andcommitted
fix toggle header example (react-navigation#1286)
1 parent c04ea5b commit b532f8c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

examples/NavigationPlayground/js/ModalStack.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ const MyNavScreen = ({ navigation, banner }) => (
2626
/>
2727
{navigation.state.routeName === 'HeaderTest' && <Button
2828
title="Toggle Header"
29-
onPress={() => navigation.setParams({ header: (!navigation.state.params || navigation.state.params.header === 'visible') ? 'none' : 'visible' })}
29+
onPress={() => navigation.setParams({
30+
headerVisible: (!navigation.state.params || !navigation.state.params.headerVisible),
31+
})}
3032
/>}
3133
<Button
3234
onPress={() => navigation.goBack(null)}
@@ -64,7 +66,9 @@ const ProfileNavigator = StackNavigator({
6466
screen: MyProfileScreen,
6567
},
6668
}, {
67-
navigationOptions: {headerVisible: false},
69+
navigationOptions: {
70+
header: null,
71+
},
6872
});
6973

7074
const MyHeaderTestScreen = ({ navigation }) => (
@@ -73,11 +77,10 @@ const MyHeaderTestScreen = ({ navigation }) => (
7377
navigation={navigation}
7478
/>
7579
);
76-
MyHeaderTestScreen.navigationOptions = ({navigation}) => {
77-
const header = navigation.state.params && navigation.state.params.header;
78-
const headerVisible = !header || header === 'visible';
80+
MyHeaderTestScreen.navigationOptions = ({ navigation }) => {
81+
const headerVisible = navigation.state.params && navigation.state.params.headerVisible;
7982
return {
80-
headerVisible,
83+
header: headerVisible ? undefined : null,
8184
title: 'Now you see me',
8285
};
8386
};

0 commit comments

Comments
 (0)