Maronato / vue-toastification

Vue notifications made easy!
https://vue-toastification.maronato.dev
MIT License
3.16k stars 143 forks source link

Toast doest not appear on refresh the page. #361

Open AlEsGoGit opened 1 year ago

AlEsGoGit commented 1 year ago

Versions

Describe the bug

Toast only shows the fist time the code compiles. If you refresh the page without changing the code the toast does not show again. If you change anything in the code and vite compiles again the toast shows once again but only one time.

Expected behavior

The toast should appear every time you refresh the page.

Steps to reproduce

Create vue 3 app and register vue-toastification. Launch toast.info("something") in the created hook of the root component. The toast only appears the first time you load the page.

Your Environment

Vue3+vite installation. Trying with hmr es-builder

SamyOuadhiGE commented 1 year ago

Hey @AlEsGoGit, Did you managed to fix it ? I have the same issue.

john-landgrave commented 1 year ago

I was having the same issue. It's not really a "fix", but a workaround is to put the toast call inside of a requestIdleCallBack() in your mounted (or onMounted if setup) hook. Should look something like this:

<script setup lang="ts">
    const toast = useToast();

    onMounted(() => {
        requestIdleCallBack(() => {
            toast.warning("Test");
        });
    });

</script>
SamyOuadhiGE commented 1 year ago

I was having the same issue. It's not really a "fix", but a workaround is to put the toast call inside of a requestIdleCallBack() in your mounted (or onMounted if setup) hook. Should look something like this:

<script setup lang="ts">
    const toast = useToast();

    onMounted(() => {
        requestIdleCallBack(() => {
            toast.warning("Test");
        });
    });

</script>

Hey @john-landgrave , worked for me with requestIdleCallback (on chrome at least). Thank you ! (I used requestIdleCallback with a 'b' lowercase, you may want to update your comment).

Edit : After some tests, requestAnimationFrame also seams to work. Maybe a better alternative to requestIdleCallback who lacks Safari support ?