cooperka / react-native-snackbar

:candy: Material Design "Snackbar" component for Android and iOS.
Other
815 stars 150 forks source link

Snackbar gets dismissed immediately when closing the Modal - Android #157

Closed durdevic closed 4 years ago

durdevic commented 4 years ago

I thought this was a fix for it but still occurs. https://github.com/cooperka/react-native-snackbar/pull/155

So I'm showing the Snack once the closeModal (made from react-native-modal component) is triggered.

On Android it gets shown for a split second and then dismissed. I thought it was because of re-rendering, but when I moved it to other component, it's the same behaviour. I also tried LENGTH_INDEFINITE, still no luck.

Is there a special way to tackle it with Modals on Android?

I also tried extracting the function and triggering it outside of the return section, still an issue.

On iOS it works smoothly.

       <FoldersListModal
                isOpen={showFolderListModal}
                closeModal={res => {
                    setShowFolderListModal(false);
                    if (res) {
                        Snackbar.show({
                            text: `Moved to `,
                            duration: 3000,
                            action: {
                                text: 'View',
                                // onPress: () => actionFunction(),
                                textColor: GREEN
                            }
                        });
                    }

                }}
            />
cooperka commented 4 years ago

Thanks for the info @durdevic. Merging into https://github.com/cooperka/react-native-snackbar/issues/28.

Please try the setTimeout workaround so the snackbar doesn't get attached to the view that's being closed.

nikita-fuchs commented 2 years ago

I have the exact same issue on desktop:

        let snackConfig : MatSnackBarConfig = {
          duration: 3000
        }
        this.snackbarRef = this.snackbar.open("Setting signature successful", "foo", snackConfig)

it appears for a brief millisecond and disappears again immediately.