davidohayon669/react-native-youtube

App crashes when return from another tab in a tab navigator

Closed this issue · 4 comments

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

Android ? iOS?

Android. Thank you, I just edited now.

I'm using a workaround with a fullscreen modal. Works pretty well, but the reported issue persists.

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 ... />}
        // ...
    }
}