Skip to content

Commit

Permalink
fix(NavBar): don't render custom BackButton if root nav state (#998)
Browse files Browse the repository at this point in the history
Avoid rendering a custom `BackButton` if the default implementation
should avoid rendering, such as when the current scene is the root
scene. Since main `state` isn't being passed to the custom component
we have no way (that I'm aware of) of determining whether it should
actually render a back button.
  • Loading branch information
blackxored authored and aksonov committed Aug 4, 2016
1 parent f7223e8 commit f541ffb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ class NavBar extends React.Component {
state.leftButtonStyle,
childState.leftButtonStyle,
];

if (state.index === 0) {
return null;
}

if (BackButton) {
return (
<BackButton
Expand All @@ -223,9 +228,6 @@ class NavBar extends React.Component {
} else {
onPress = Actions.pop;
}
if (state.index === 0) {
return null;
}

let text = childState.backTitle ?
<Text style={textButtonStyle}>
Expand Down

0 comments on commit f541ffb

Please sign in to comment.