Reputation: 1697
I am looking at this source code.
render() {
const { value, onChange, options } = this.props
return (
<span>
<h1>{value}</h1>
<select onChange={e => onChange(e.target.value)}
value={value}>
{options.map(option =>
<option value={option} key={option}>
{option}
</option>)
}
</select>
</span>
)
}
my question is, why the event handler is onChange
? I think the standard html attribute is onchange
. and unfortunately, I cannot find any react document about the event handler names
thanks
Upvotes: 0
Views: 253
Reputation: 24815
Firstly, HTML attributes are case insensitive, so onchange
, onChange
and ONCHANGE
are all equivalent in HTML.
However, JSX is not HTML. In React, case is important, so onChange
it must be.
The select
element in React also differs in other ways from the select element in HTML. For instance, value
is defined on the select
element, making the selected
attribute on the option
element obsolete.
Upvotes: 1
Reputation: 5838
Event is defined as onChange in ReactJS: https://facebook.github.io/react/docs/events.html
You have some examples of use in ReactJS documentation website: https://facebook.github.io/react/docs/forms.html
Upvotes: 0