简体   繁体   中英

How to trigger native event in React?

I'm creating a custom input tag, PhoneInput . It has 3 inputs inside, so I need to parse them, and concat back to string. I want to pass in onChange callback SyntheticEvent , like React does. So I need to create hidden input:

<input onChange={this.props.onChange} value={this.state.value}/>

But when I change state, event didn't triggers. How to do it right? http://jsbin.com/bahuyuriqa/1 - here is example.

Change events, it seems, are only fired from user input. Is there a specific reason you would need an onChange handler on the hidden input? If you do need access to the native event from the synthetic event , you can simply access it via e.nativeEvent

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM