App crashes when return from another tab in a tab navigator
Closed this issue · 4 comments
mauriciosoares01 commented
The app has the following navigation structure:
Home
VideoPlayer
Playlists
Configs
In home there is a video's list, so the video player screen is called when an video e touched in the home screen. If the user switch for another tab and back to the home tab (where the VideoPlayer is loaded) the app crashes.
Environment:
Platform: Android (wasn't tested in iOS)
react-native-youtube: ^2.0.0
@react-navigation/bottom-tabs: ^5.0.5
react-native: 0.61.5
davidohayon669 commented
Android ? iOS?
mauriciosoares01 commented
Android. Thank you, I just edited now.
mauriciosoares01 commented
I'm using a workaround with a fullscreen modal. Works pretty well, but the reported issue persists.
extracold1209 commented
I had same issue and I resolved below way
import { useIsFocused } from '@react-navigation/native'
const Layout: React.FC = () => {
const isFocused = useIsFocused();
return (
// ...
{isFocused && <YouTube ... />}
// ...
}
}