Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only able to open one toast once #62

Open
eghernqvist opened this issue Jun 23, 2016 · 4 comments
Open

Only able to open one toast once #62

eghernqvist opened this issue Jun 23, 2016 · 4 comments

Comments

@eghernqvist
Copy link

Once I've had a toast triggered I cannot trigger another until a fresh page reload has been done.

Here's my code:

var ReactToastr = require('react-toastr');
var { ToastContainer } = ReactToastr;
var ToastMessageFactory = React.createFactory(ReactToastr.ToastMessage.animation);

render() {
  return(
    <div>    
      <ToastContainer ref="container" toastMessageFactory={ToastMessageFactory} />
    </div>  
  );
}

syncToast(message) {
  this.refs.container.success(
    "",
    message, {
    timeOut: 5000
  });
}

sync(id) {
  this.syncToast("Sync successful.")
}

The sync method gets called when I press a button, other things such as console.log and debugger gets triggered fully but not the toast.

@RangarajKaushikSundar
Copy link
Collaborator

@eghernqvist In the options, try sending preventDuplicates:false. Kindly let us know if the issue persists.

@lednhatkhanh
Copy link

That doesn't help, the toastr still happens once.

@eghernqvist
Copy link
Author

What @lednhatkhanh wrote. Due to short deadline we had to move to use a different toast implementation.

@elkinjosetm
Copy link

elkinjosetm commented Jan 10, 2017

@lednhatkhanh @eghernqvist To be able to add multiples notifications you just need to add preventDuplicates={false} as a prop of the ToastContainer component. Example:

notify ( type, event ) {
	event.preventDefault();

	const optionsOverride = {
		showAnimation     : 'animated flipInX',
		hideAnimation     : 'animated flipOutX'
	};

	this._notificationSystem._notify( type, "Message", "Title", optionsOverride );
},

render () {
	return (
		<div>
			<button onClick={ this.notify.bind( null, 'success' ) }>Success notification</button>
			<button onClick={ this.notify.bind( null, 'error' ) }>Error notification</button>
			<button onClick={ this.notify.bind( null, 'info' ) }>Info notification</button>
			<button onClick={ this.notify.bind( null, 'warning' ) }>Warning notification</button>
			<ToastContainer
				ref={ ref => this._notificationSystem = ref }
				className="toast-top-right"
				preventDuplicates={ false }
			/>
		</div>
	);
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants