Skip to content

Commit

Permalink
Add method for replacing messages of Message component
Browse files Browse the repository at this point in the history
By first clearing messages with setState and then
provide a callback to set new messages we ensure
that the state has been updated before we try
to add new messages that are to replace existing
ones.

Fixes primefaces#930
  • Loading branch information
partynikko committed Jun 19, 2019
1 parent 3ca2147 commit ba9c605
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/messages/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export class Messages extends Component {
})
}

replace(messages) {
this.setState(
{
messages: [],
},
() => this.show(messages)
);
}

onClose(message) {
let newMessages = this.state.messages.filter(msg => msg.id !== message.id);
this.setState({
Expand Down

0 comments on commit ba9c605

Please sign in to comment.