React报错之React hook 'useState' cannot be called in a class component

正文从这开始~ 总览 当我们尝试在类组件中使用useState 钩子时,会产生"React hook 'useState' cannot be called in a class component"错误。为了解决该错误,请将类组件转换为函数组件。因为钩子不能在类组件中使用。 这里有个例子用来展示错

你可能感兴趣的:(React报错之React hook 'useState' cannot be called in a class component)