0

I am using react-native-router-flux for the navigation in my react-native mobile app.

I want to call Actions.sceneKey() from drawer using a variable sceneKey which will be based on the store state. Let's say, there are 3 menus in drawer:

  • menu1
  • menu2
  • menu3

I just want to call Actions.{{ selectedMenu }}, is this somehow possible?

Makyen
  • 31,849
  • 12
  • 86
  • 121
NooB8374
  • 99
  • 12
  • Do you want to navigate to another menu? I am doing this by calling Actions.home()// in case home is my scene key. You can also pass parameters Actions.home({key:value}). You can use switch case or of condition to know current menu and call it using above syntext. – Haroon Apr 02 '17 at 04:26

1 Answers1

0

You can use bracket notation, see property accessors. Here is a example of how you can use it:

const selectedMenu = 'menu1'; //menus values coming from your store
Actions[selectedMenu]();

Make sure the variable is of type string and matches one of your defined routes.

Fidan Hakaj
  • 6,818
  • 3
  • 30
  • 33