Bind Event Handlers to Components
so why from the first place i could have used "this" in the render() method? in a way it's also a custom method within the class.
I guess that is because React calls render() method on your component (instance of Counter class which extends React.Component) e.g. counterObj.render(). So React takes care of the right context of "this" inside render(). But onClick handler is called simply as a function (not as a method on counterObj). You can even pass a function that is defined outside of your component's class, to onClick="...".
Posting to the forum is only allowed for members with active accounts.
Please sign in or sign up to post.
I forgot my password