Why is this not scoped in React form onSubmit function?

Viewed 3386

In my React component I have a form with onSubmit function

<form className="form-horizontal" name="taskForm" onSubmit={this.submitTask}>

submitTask(e) {

  e.preventDefault();
  console.log(this.props);  // undefined
  console.log(this) // window object
}

For some reason this.props is not in scope when I use form onSubmit. When I console.log(this.props) in the constructor, props logs out normally.

When I console.log(this) it is the window object. How do I get the scope of the react component?

1 Answers
Related