javascript - React JS: Pass event inside onChange drop down (Ant Design) -
i have drop down in form (https://ant.design/components/select). in select drop down have onchange call function. inside 'onchange' want pass event parameter function. problem is: when onchange occurs, selected value passed, want entire event.
here code:
export default class myform extends component { constructor() { super(); this.handleonchange = this.handleonchange.bind(this); } handleonchange = (event) => { console.log(event); // here i'm receiving value selected (1 or 2) } render() { render( <form> <select onchange={this.handleonchange}> <option value="1">text 1</option> <option value="2">text 2</option> </select> </form> ) } }
in console.log() i'm receiving selected value. there way pass entire event object function handleonchange()?
the select
component use 1 handle onchange
, call "outer" function.
what can try use synthetic event variable inside function, might work:
handleonchange = (selectedvalue) => { console.log(selectedvalue); // value inner component console.log(event); // have access variable }
Comments
Post a Comment