You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When wanting to show only a single message (the latest) in a particular area of the application, one would expect that calling clear() and then show({ ... }) would achieve this. However, when calling clear() followed by show(), the call to clear() is ignored, and new messages keep being added.
OK you don't want to call clear() then show() because both update the same state variable in the hook. That is why there is the replace method to accomplish exactly what you want in1 line effectively calling clear and show together.
messages.current.replace(newMessages);
however I found a bug in it which I am fixing for 8.2.0
melloware
added a commit
to melloware/primereact
that referenced
this issue
May 25, 2022
Describe the bug
When wanting to show only a single message (the latest) in a particular area of the application, one would expect that calling
clear()
and thenshow({ ... })
would achieve this. However, when callingclear()
followed byshow()
, the call toclear()
is ignored, and new messages keep being added.Reproducer
https://codesandbox.io/s/dreamy-mccarthy-8u7oui?file=/src/demo/MessagesDemo.js
PrimeReact version
8.0.1
React version
18.x
Language
ALL
Build / Runtime
Create React App (CRA)
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
No response
The text was updated successfully, but these errors were encountered: