Hi, I’m solving the challenges without problems, but I’m struggling to understand about this handleChange property in the React lessons. Here is an exemple code:
The handleChange property is a custom react property? What is this event parameter that I’m not passing but the function is receiving ? Can I just create my own custom properties just like this? Please, explain to me what is happening under the hood!
Thanks for the help and sorry if there are any weird parts in my questions, I’m not very proficient in English.
if you look at this line in the render area which creates a input line and then invokes the function this.handleChange whenever someone changes anything in the input area (add/delete). This part is the ‘react’ part. but the actual function being called can be anything (any function name that handles the input).
thanks. Follow up question. Why do they define handleChange function outside of GetInput? Why not just put it inside GetInput since that is the one using it?
Randell, can you please explain how the event object is being passed to the handleChange function? I’m a bit confused since I doesn’t see the function being called nor this parameter passed. Thanks in advance.
Hi, just wanted to show you how the onChange event triggers the code for handleChange
It is done in the code section above. ‘onChange’ is a synthetic event that React gives us and we tell it what to do by assigning the related handler… (the related handler can be called anything we like but the synthetic event name is fixed)