3

I have an app that uses React navigation to navigate, and in my app I made an audioplayer component that uses React Native Sound. My question is, how can I stop the audio when the user navigates to another view?

I've found the function onNavigationStateChange on the navigator which is being called, but I don't know how to connect that to my audioplayers?

<Provider store={this.state.store}>
<AppNavigator ref={(nav) => { this.navigator = nav; }} onNavigationStateChange={()=>{console.log('now i should stop audio');}}  />
</Provider>
Niels
  • 1,340
  • 2
  • 15
  • 32

0 Answers0