Tell us what’s happening:
I saw it from the get a hint section while exercising by myself binding this while calling the function is illogical for me, cause we have already had bind this.
Your code so far
<input onChange = {this.handleChange.bind(this)}/>
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36
.
Challenge: Create a Controlled Input
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
nibble
September 12, 2020, 1:11pm
#2
Hi @nuruddinshohan . There is a comprehensive answer to your question in this article .
yeah, I understand why we have to use bind. But in get a hint section of the exercise
bind is used in calling the function, without it code works perfectly and gets accepted too.
nibble
September 12, 2020, 1:31pm
#4
There is this statement in the hint.
PS - Here is another way to bind this
into a function: <input onChange = {this.handleChange.bind(this)}/>
The above is an alternative to:
this.handleChange = this.handleChange.bind(this)
1 Like