Skip to content

Commit

Permalink
feat(ToastContainer): add props.preventDuplicates suppory
Browse files Browse the repository at this point in the history
* Thanks to @RangarajKaushikSundar 
* Original commit: 00817d9
* Original commit: 87e38e4
* Closes #58 
* Closes #56 
* Closes #53
  • Loading branch information
RangarajKaushikSundar authored and tomchentw committed Jun 14, 2016
1 parent 648331e commit b8e9bd2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ToastContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {},
};
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b8e9bd2

Please sign in to comment.