Answer the question
In order to leave comments, you need to log in
How to pass multiple parameters to an event handler in a React component?
How to pass multiple parameters to an event handler in a React component? I tried the option
<input onInput={this.handleEvent.bind(this, "SOME TEXT", 0)} />
<input onInput={this.handleEvent.bind("SOME TEXT", 0)} />
handleEvent = (theEvent, theText, theNumber) => {
alert(theEvent.target.value);
alert(theText);
alert(theNumber);
}
Answer the question
In order to leave comments, you need to log in
//функция
handleEvent= (arg1, arg2, arg3) => (e) => {
console.log(e.target.value); //значение инпута, если надо
console.log(arg1); //аргумент 1
console.log(arg2); //аргумент 2
console.log(arg3); //аргумент 3
}
//вызов
<input onInput={this.handleEvent(arg1, arg2, arg3)}/>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question