Kureev / Kureev/react-native-navbar

Different left button on different screens

Open
#211 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.9k
Forks
318
PR merge metrics
No merged PRs in 30d

Description

I want to have burger button for drawer opening when there is only one route in stack. When we pushed a route to navigator I want to display back button. I wrote this code to handle this logic:

```
@autobind
renderLeftButton(routes) {
if (routes.length === 1) {
return (



);
}

return (

);
}

render() {
const currentRoutes = this.props.navigator.getCurrentRoutes();
const currentRoute = currentRoutes[currentRoutes.length - 1];
const tintColor = '#ffffff';
const {
props:{
title = currentRoute.title,
}
} = this;

let leftButtonConfig = {
tintColor,
title: this.renderLeftButton(currentRoutes),
};

const titleConfig = {
tintColor,
title,
};

if (currentRoutes.length === 1) {
leftButtonConfig.handler = this.props.openDrawer;
} else {
leftButtonConfig.handler = this.props.navigator.pop;
}

return (

)
}
```

The problem is no component updates on navigator.pop action. So the appearance of buttons don't change. Does anybody know the right solution to get this work?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by examining the NavigationBarOrig component and the navigator.pop action described in the issue, then trace how the current routes reach renderLeftButton. Reproduce the route-stack transition and verify that the left button changes between the drawer and back states after navigation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.