GeekyAnts / NativeBase

Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.
https://nativebase.io/
MIT License
20.2k stars 2.39k forks source link

Toast Issue with React Native App in background or closing app #2737

Closed mohit-brainizen closed 2 years ago

mohit-brainizen commented 5 years ago

Hi Guys, I am facing this issue with my RN application

First of all I'm using the native bas eversion 2.12.1 and RN version 0.55.4. The Toast is perfectly working but there is one issue I found which the error evaluating 'this.toastInstance._root' Error when using Toast was showing when I do this steps.

First I newly open my app, then tried to test out the toast which perfectly works. Then I tried to go on different screen using the react-navigation and still it works fine. If I use my Android back button, it will close the App. then if I open again my app, and tried to check out the Toast, the error shows up. It seems the tag on my main App is disappear which the error occur when I test the Toast again. I have tried everything from the comments on this issue https://github.com/GeekyAnts/NativeBase/issues/1121 Please if anyone can look into this. thanks,

hanykumar commented 4 years ago

Hi @mohit-brainizen , can you provide minimal code reproduction on snack for the same?

mohit-brainizen commented 4 years ago

@hanykumar Below is the code for my App.js

export default () => (

    <Root>
        <MenuProvider>
            <Provider store={store}>
                <NetworkProvider  pingInterval={15000} >
                <AppDrawerNavigator uriPrefix={prefix}/>
                </NetworkProvider>
            </Provider>
        </MenuProvider>
    </Root>
);
export const showInternetToast = (isFocused, refreshFunction, withoutHeader=false) => {
    if(isFocused) {
        Toast.show({
            textStyle: {
                fontSize: wp('4.5%'),
                textAlign: 'center'
            },
            buttonTextStyle: {fontSize: wp('4%')},
            text: 'No Internet !',
            buttonText: 'Try Again',
            onClose: (reason) => {
                //This is because the toast component closes when
                // pressed onClose, so we implicitly check if
                // internet is connected, if not we show the toast
                // component again
                if (!internetConnected) {
                    showInternetToast(isFocused, refreshFunction)
                } else {
                    if (reason == 'user') {
                        refreshFunction()
                    }
                }
            },
            position: 'top',
            style: withoutHeader ? {marginTop: wp('6%')} : {marginTop: wp('16.2%')},
            duration: 3000000
        })
    }
}`

This above function shows the toast

hanykumar commented 4 years ago

Hi @mohit-brainizen , we are unable to reproduce the same. Kindly provide minimal code reproduction on snack.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.