root-two / react-native-drawer

React Native Drawer
MIT License
2.54k stars 390 forks source link

Cannot slide to close when setState #278

Open chankung opened 7 years ago

chankung commented 7 years ago

Here's my Drawer.

`<Drawer ref={(drawer) => { !this.state.drawer ? this.setDrawer(drawer) : null }} type={'overlay'} openDrawerOffset={100} closedDrawerOffset={0} captureGestures={true} panOpenMask={.1} panCloseMask={.9} relativeDrag={false} panThreshold={.25} content={Test} styles={drawerStyles} disabled={false} tweenDuration={350} tweenEasing={'linear'} acceptDoubleTap={false} acceptTap={false} acceptPan={true} tapToClose={true} negotiatePan={true} side={'left'}

`

Here's setState funtion

setDrawer = (drawer) => { this.setState({ drawer }); // return drawer; };

It can slide to open but cannot slide to close.

lwx123 commented 7 years ago

+1

AhmedAliIbrahim commented 7 years ago

+1

VahidBo commented 7 years ago

Hi use the open prop to solve this problem.

<Drawer ...
open={this.state.drawer}
... > <Content/> </Drawer>

call setDrawer(true) to open the drawer and call setDrawer(true) to close the it.