fkhadra / react-toastify

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

Unexpected behavior with combination: update & limit #824

Open KubaChoice opened 2 years ago

KubaChoice commented 2 years ago

When you try following code when toast container have set limit=1, expected behavior should be same in both runs, but it is not, in the second run it shows fist message and not last (updated):

function onClick() {
  const id = toast.success('a')
  toast.update(id, {render: 'b'})
  toast.update(id, {render: 'c'})
}

onClick();
onClick();

During first "onClick()" run is eventually (instantly) showed 'c' After close (manually or after time out), second "onClick()" show 'a' (even twice - but this can be related with another issue)

fkhadra commented 2 years ago

@KubaChoice can you reproduce the issue on codesanbox or share a repository thank you

KubaChoice commented 2 years ago

Hi There it is: https://codesandbox.io/s/toastify-update-que-issue-eo21yj?file=/src/index.js

This is very nice tool, however working with queue is limited, it is pity Working with queue (in my case) missing at least following:

In this case I'm "forced" to write own queue Still nice tool

fkhadra commented 2 years ago

Hey @KubaChoice, you're right. update only works with active notification. I think I could address the following point in a future version as they make sense

Regarding add/relocate notification (id) to queue to specified position, not too complicated to implement but It might require a bit more time to get the API right.