[英]Where to use Usestate hook in react component
您不能在 class 组件中使用useState
。 您需要一个功能组件。
这是文档
这是您的示例的代码:
import React, { useState } from 'react';
function VoiceCallComponent() {
const [val, setVal] = useState(7);
// rest of the component logic goes here
return (
// JSX
)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.