this.container not working
planetwebsolution opened this issue · 3 comments
planetwebsolution commented
I got can not read container of undefined. below is my snippet
import { ToastContainer, ToastMessage } from 'react-toastr';
const ToastMessageFactory = React.createFactory(ToastMessage.animation);
addAlert () {
this.container.success(
"my-title",
"my-fascinating-toast-message", {
timeOut: 5000,
extendedTimeOut: 3000
});
}
render() {
return (<div>
<ToastContainer ref={(input) => {this.container = input;}}
toastMessageFactory={ToastMessageFactory}
className="toast-top-right"
preventDuplicates="true" />
<button onClick={this.addAlert}>Add Toast</button>
</div>);
}
mclapa commented
@planetwebsolution the documentation says
`let ReactToastr = require("react-toastr")
let {ToastContainer} = ReactToastr
let ToastMessageFactory = React.createFactory(ReactToastr.ToastMessage.animation)`
but not sure if that will fix your problems
tomchentw commented
Did your console has errors?
whns commented
You need to import React as well, if you haven't already. The example assumes usage within an existing component.