cooperka/react-native-snackbar

Snackbar gets dismissed immediately when closing the Modal - Android

durdevic opened this issue · 2 comments

I thought this was a fix for it but still occurs. #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
                            }
                        });
                    }

                }}
            />

Thanks for the info @durdevic. Merging into #28.

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

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.