[英]Best Event Handler for capturing and storing the data entered in React Js Application
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.您需要 onChange 事件处理程序来获取输入的值。 It would look like this:
它看起来像这样:
onChange={e => setText(e.target.value)}
Using useState
hook:使用
useState
钩子:
const [text, setText] = useState('')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.