fkhadra / react-toastify

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

Notification center: data rehydradation - TOAST_ID hardcoded to 1 #1027

Open bluelakee02 opened 6 months ago

bluelakee02 commented 6 months ago

Hi, there is hardcoded TOAST_ID starting always at 1 LN

Case: you make a toast, it gets id: 1, you get in Notification center notification with id: 1 and sync it to localStorage. Then you refresh browser and rehydrate Notification center from localStorage. You still have persisted notification with id: 1. You make a new toast and it gets again id: 1, you get it in Notification center where it overrides the previously stored notification with same id.

My workaround is, that I am storing notifications, with new ids. But I am not sure if that was intended, it would be more consistent to store original ids.

Solution - simple one fe. add another argument - toastIdUpdate? to useNotificationCenter function, which would update default TOAST_ID. More complicated - find last id in data passed for rehydratation.

I am willing to make PR, but to busy right now.