javascript - 如何解决 Hooks 上的这个 React 类型错误?
问题描述
const isSignUp = false;
const handleChange = () => {};
const [showPassword, setShowPassword] = useState(false);
const handlePassword = () =>
setShowPassword((prevShowPassword) => !prevShowPassword);
我正在使用 usestate 实现密码显示/隐藏功能,但我不明白为什么会出现此错误。帮忙看看怎么解决?
解决方案
解决了 !
当我有这个错误时:
import useState from "react";
当我把它改成这个时它得到了解决:
import { useState } from "react";
推荐阅读
- php - 有没有更好的方法来为我的页脚轮播数据对象编写函数
- reporting-services - 一个数据集控制 SSRS *.rdl 中的其他数据集?
- r - R:在 Ubuntu 18.04 上带有安装箭头的箭头
- java - Spring调度程序未按计划启动
- docker - 运行 docker 容器错误:找不到可服务模型的基本路径 /models/model
- typescript - 有多种类型实现,但根据 Typescript 中的条件,只有一个处于活动状态
- c++ - Get decimal value of Unicode Character C++
- python - 即使 api 服务器端响应已完成,Python get 请求也会长时间挂起 api 调用
- reactjs - 如何在 React hook..useEffect 中重新渲染子组件
- python - 在 LXML 中,如何保留标签,但删除所有内联样式等?