aksonov / aksonov/react-native-router-flux

Current status of Drawer opened/closed?

未關閉
#3,530 2 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
8.9k
分支
2.1k
PR 合併指標
30 天內沒有已合併 PR

描述

### 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!

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。