我希望我不是在重复一个问题。我见过这个:TypeError dispatcher.useState is not a function when using React Hooks,但是我的应用程序运行良好,它只是 Flow 中的一个错误:
Cannot import `useState` because there is no `useState` export in `react`.
4| import { useState } from 'react';
我正在使用16.7.0-alpha
我的 react 和 react-dom 依赖项:
"dependencies": {
...
"react": "^16.7.0-alpha",
"react-dom": "^16.7.0-alpha"
},
这是我从 Flow 中得到的唯一错误,其他 React 元素都很好。我的依赖项有问题吗?
这是我文件的顶部:
// @flow
import React from 'react';
import { useState } from 'react';
编辑:我还进入了我的 node_modules/react 文件夹并验证了该useState
功能确实在那里。