The onPress
prop takes a function, and only a function. There is no syntax for automatically combining two funtions in Javascript. You need to create a new function which executes both actions.
<Button
onPress={(e) => {
Actions.Main1(e);
Actions.Tab2(e);
}}
style={{ width: 90, height: 90 }} >
<Text>Show</Text>
</Button>
Some notes:
- I passed the event parameter into both of the actions, since passing just one of the functions (i.e.
onPress={Actions.Main1}
) itself would pass this parameter as well. This may not be necessary in your case.
- The slight issue with this code is that creates a new function every time the
render
function of this component is called. It's not terrible, but also not ideal. Consider that in the future. I include that optimization in this post because a) we don't see the rest of the implementation of the component, b) I think this question was rudimentary enough for us to just worry about the main concept.