react-toastify icon indicating copy to clipboard operation
react-toastify copied to clipboard

Notification center: data rehydradation - TOAST_ID hardcoded to 1

Open bluelakee02 opened this issue 2 years ago • 0 comments

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.

bluelakee02 avatar Dec 05 '23 00:12 bluelakee02