I have created an input textbox for entering items details. To capture and store the data entered, which among below mentioned event handler is the best?
- onClick
- onChange
- onLoad
- onKeyPress
I have created an input textbox for entering items details. To capture and store the data entered, which among below mentioned event handler is the best?
You need the onChange event handler to get the value of the input. It would look like this:
onChange={e => setText(e.target.value)}
Using useState hook:
const [text, setText] = useState('')