From b8e9bd24b7fd73aa88c1cf1259befe608c7382e3 Mon Sep 17 00:00:00 2001 From: Rangaraj Kaushik Sundar Date: Mon, 13 Jun 2016 20:22:50 -0700 Subject: [PATCH] feat(ToastContainer): add props.preventDuplicates suppory * Thanks to @RangarajKaushikSundar * Original commit: 00817d9bb91a285204c71d444c640b183ab1976d * Original commit: 87e38e45b7d5ae3ab33e39ab0d37c8c6ac50ddd6 * Closes #58 * Closes #56 * Closes #53 --- src/ToastContainer.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ToastContainer.js b/src/ToastContainer.js index 7dbffd4..ba04f57 100644 --- a/src/ToastContainer.js +++ b/src/ToastContainer.js @@ -36,8 +36,8 @@ export default class ToastContainer extends Component { warning: `warning`, }, id: `toast-container`, - toastMessageFactory: React.createFactory(ToastMessage), - preventDuplicates: false, + toastMessageFactory: React.createFactory(ToastMessage.animation), + preventDuplicates: true, newestOnTop: true, onClick() {}, }; @@ -116,6 +116,9 @@ export default class ToastContainer extends Component { } _handle_toast_remove(toastId) { + if (this.props.preventDuplicates) { + this.state.previousMessage = ``; + } const operationName = `${this.props.newestOnTop ? `reduceRight` : `reduce`}`; this.state.toasts[operationName]((found, toast, index) => { if (found || toast.toastId !== toastId) {