Skip to content

State issues with react 19 #1275

@nynevi

Description

@nynevi

react: 19.2.4
toastify: 11.0.5

Screen.Recording.2026-02-11.at.17.58.55.mov

reading the code, dismiss does markAsRemoved https://github.com/fkhadra/react-toastify/blob/main/src/core/containerObserver.ts#L52

it does not really remove the toast. the onChange does not fire either https://fkhadra.github.io/react-toastify/listen-for-changes
next time toast() is triggered, the onChange fires with the new toast status: added and then after that one the previous one is really removed with status: removed. this causes the behavior in the video.

the code seems that it should work nonetheless but I am guessing thats due to react: 19.2.4

the listeners has the following:

function() { checkIfSnapshotChanged(inst) && (startUpdateTimerByLane(2, "updateSyncExternalStore()", fiber), forceStoreRerender(fiber)); }

from the react-dom source code:

function subscribeToStore(fiber, inst, subscribe) {
        return subscribe(function() {
            checkIfSnapshotChanged(inst) && (startUpdateTimerByLane(2, "updateSyncExternalStore()", fiber), forceStoreRerender(fiber));
        });
    }

most likely has to do with how react 19 uses https://react.dev/reference/react/useSyncExternalStore

I also noticed that it bugs out with multiple toasts

got no reproducable link unfortunately.

patches

  • add the below to onClose of the options passed for the toast
toast.update('THE ALERT ID', {
    render: () => null,
    containerId: 'THE CONTAINER ID', //remove when not using containers
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions