Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show DrawerLayoutAndroid via ToolbarAndroid => onIconClicked

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

like image 674
Maslow Avatar asked Sep 20 '15 14:09

Maslow


1 Answers

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();
like image 182
kzzzf Avatar answered Oct 21 '22 08:10

kzzzf