aksonov / aksonov/react-native-router-flux

Current status of Drawer opened/closed?

Open
#3,530 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8.9k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

### Version
Tell us which versions you are using:

- react-native-router-flux v4.0.6
- react v16.8.3
- react-native v0.59.5

### Expected behaviour

`Actions.state` contains `isDrawerOpen:false/true`

### Actual behaviour

`Action.state` does not contain `isDrawerOpen` anymore
it only contains >

```
index: 0
isTransitioning: true
key: "StackRouterRoot"
routes: [{…}]
```

### Explanation
I have a little wrapper component (if that's what it's called) where i registered a listener `BackHandler.addEventListener("hardwareBackPress", this.handleBackPress);` and I need it to operate conditionally based on whether the drawer is opened or closed. If closed > exit app and so on.

In a previous project I used the same exact wrapper component and was able to access `isDrawerOpen` via `Actions.state`. I am using `RNRF v4.0.6` over there too.

I did try to use the drawer's onExit/onEnter methods in my Router component like so:

```
{
this.setState({ _DrOpen: false });
}}
onEnter={() => {
this.setState({ _DrOpen: false });
}}
contentComponent={DrawerContent}
drawerWidth={300}
hideDrawerButton
>
```
and then pass that `_DrOpen` as a prop to my wrapper, but that would cause the router component to re-render and I have to control that. So, much code for a little function in my opinion.
So, before I go there, is there a straight forward way to know whether the drawer is closed/opened?
Thank you in advance!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.