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

this.container not working #123

Open
planetwebsolution opened this issue Sep 26, 2017 · 3 comments
Open

this.container not working #123

planetwebsolution opened this issue Sep 26, 2017 · 3 comments

Comments

@planetwebsolution
Copy link

planetwebsolution commented Sep 26, 2017

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
Copy link

mclapa commented Oct 12, 2017

@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
Copy link
Owner

Did your console has errors?

@whns
Copy link
Contributor

whns commented Oct 13, 2017

You need to import React as well, if you haven't already. The example assumes usage within an existing component.

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

No branches or pull requests

4 participants