Reputation: 6854
I am struggling to understand what the assigned onChange property means in the following TextField component (from material-ui library):
<TextField style = {{"padding":"10px","width":"100%"}}
type = {'number'}
value = {this.props.count.value}
onChange={(event, newValue) => this.props.onChange(newValue, ID, "count")} />
There is no object/data being passed through with an onChange function attribute... from the higher level component ?
So what does the entire function mean ? It seems very confusing.
Thanks in advance.
Upvotes: 0
Views: 582
Reputation: 16441
onChange
is handled by the TextField
component. When they invoke the onChange
function, it gets two arguments, event
and newValue
. What your doing is specifying an inline onChange
handler that uses one of those two arguments to call this.props.onChange
with the value from the text input and also some other values that are not.
Upvotes: 1