fkhadra / react-toastify

React notification made easy 🚀 !
https://fkhadra.github.io/react-toastify/introduction
MIT License
12.3k stars 676 forks source link

toast.update (unexpectedly) requires container id #1080

Open janpaepke opened 3 months ago

janpaepke commented 3 months ago

Do you want to request a feature or report a bug? I'm pretty sure this is an unintentional bug.

What is the current behavior? When specifying a containerId when caling toast(), an update to the resulting toastID will fail silently (it just does nothing).

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:

The code below fails, which at least to me is unexpected as toastIDs are globally unique, not per container.

const currentID = toast('first', {
    containerId: 'chat',
});

setTimeout(() => {
    toast.update(currentID, {
        render: 'second',
    });
}, 2000);

See here for the codesandbox example.

What is the expected behavior? I would expect the update to work without passing the containerId.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? independent of React.

aemendes commented 3 months ago

Currently facing the same problem.

In my case when toaster.update is at same level of ToasterContainer I have this problem. If i move toaster.update to some downstream children it starts working as expected.

I can see that containerIds are well generated without having any conflict, just the rendering is not working as expected.