I can not image the use case of a function was not bond by this object. I think all of the functions need to be bond by this. So why Reactjs doesn't set bind(this) by default? For example the following code, if I didn't set bind(this) the functions would be useless, right?
class App extends React.Component {
constructor(props) {
super(props)
this.state = { username: '' }
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(ex) {
this.setState({ username: event.target.value })
}
handleSubmit(event) {
event.preventDefault()
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<input
type="text"
value={this.state.username}
onChange={this.handleChange}
/>
<input type="submit" value="Submit" />
</form>
)
}
}