#How to pass a function and also a statement inside the onChange event

2 messages · Page 1 of 1 (latest)

oak badger
#

Hi all! I need to pass a function and also a statement inside the onChange event in React but I am facing some problems here!
This is my code:
onChange={e => {handleNumChange(e) ; text => {
text && secondInput.current.focus();
}}
There is anyone that can help me?
Thanks

vagrant remnant
#

I'm not sure if this solves your specific problem, but you could pass that variable into your function:

function handleNumChange(event, text){
  //do whatever you need with event
  if(text) secondInput.current.focus();
}
return(
<div onChange={ (e) => handleNumChange(e,text) } />
)
}}