Skip to content

In Transferring Props guide, Manual Transfer section will lead an error #2648

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

Closed
cookfront opened this issue Dec 3, 2014 · 3 comments
Closed

Comments

@cookfront
Copy link
Contributor

var FancyCheckbox = React.createClass({
  render: function() {
    var fancyClass = this.props.checked ? 'FancyChecked' : 'FancyUnchecked';
    return (
      <div className={fancyClass} onClick={this.props.onClick}>
        {this.props.children}
      </div>
    );
  }
});
React.render(
  <FancyCheckbox checked={true} onClick={console.log}>
    Hello world!
  </FancyCheckbox>,
  document.body
);

When click Hello world! will lead a Uncaught TypeError: Illegal invocation error

@bloodyowl
Copy link
Contributor

that's because console.log needs console as thisValue and isn't bound to it when you pass it like this.
pass console.log.bind(console) and you're good to go.

@cookfront
Copy link
Contributor Author

Thanks for reply.So I pull an request 218a9ae

@zpao
Copy link
Member

zpao commented Dec 5, 2014

Closed by #2649

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

3 participants