react-nativereact-native-navigationwix-react-native-navigationreact-native-navigation-v2

React-Native-Navigation (v2) Bottom Tab onPress


I have a Bottom Tab with a Play Button in the middle, I would like to fire a function instead of load a registered screen.

Right now I have:

children: [
    {
      component: {
        id: 'player' 
        name: 'navigation.PlayerScreen',
        passProps: {
          text: 'Player',
        }
      }
    }
  ],

I´m searching if there´s something like that without the need of a screen:

children: [
    {
      component: {
        id: 'player'
        onPress: () => playMusic()
      }
    }
  ],

Versions:

Thanks in advance.


Solution

  • This is not possible.

    You can do it like this;

    1. Create a component called PlayMusic
    2. Connect onPress to PlayMusic component
    3. Define the PlayMusic component to wix's and then define component.name.

    If you want to send parameters to the function, you can use passProps. (Remember to update the PlayMusic component)