I'm new to React native (and React) and I'm playing around a little bit with it.
I managed to add a DrawerLayout that I can drag from the left of my screen. However I'd like to open it when I click on my menu icon in my ToolbarAndroid.
I tried to use "refs" but it doesn't seem to work
I hope I'm clear enough.
Thank you
You should use "refs" as you've mentioned. To do so, for your drawer component have "ref" attribute set:
<DrawerLayoutAndroid
...
ref={'DRAWER_REF'}
...
/>
Then in your component use this.refs
to access it and call openDrawer
or closeDrawer
on that ref (e.g. you may want to have Touchable
element that will trigger this call):
this.refs['DRAWER_REF'].openDrawer();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With