[英]React 16.7 TypeError: (0 , _react.useState) is not a function
Error:错误:
TypeError: (0 , _react.useState) is not a function
Error:错误:
TypeError: (0 , _react.useState) is not a function
My current react versions:我目前的反应版本:
"react": "^16.7",
"react-dom": "^16.7",
src/App.js:源代码/App.js:
import {memo, useState} from 'react'
export default memo(() => {
useState(false)
return 'OK'
})
src/App.test.js: src/App.test.js:
import React from 'react'
import App from './App'
import renderer from 'react-test-renderer'
it('renders without crashing', () => {
const tree = renderer.create(<App />).toJSON()
expect(tree).toMatchSnapshot()
})
How to resolve this issue?如何解决这个问题?
Questing posted 3 years ago but maybe sommeone is sufering with the same problem) In my case the mistake was in the imports. Questing 于 3 年前发布,但也许有人遇到同样的问题)在我的情况下,错误在于进口。 My IDE imported the useState hook from import 'react\/cjs\/react.development' and it dosen't work on production.我的 IDE 从 import 'react\/cjs\/react.development' 导入了 useState 挂钩,但它在生产环境中不起作用。
"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.