define interface:

interface ILoginState {
imageId: string;
imageSrc: string;
username: string;
password: string;
verifyCode: string;
}

useState:

const [loginData, setLoginData] = useState(loginState)

update imageId && imageSrc:

setLoginData({
...loginData,
imageId: res.data.id.
imageSrc: res.data.content
})

antd inputchange:

onInputChange(e: FormEvent<HTMLInputElement>) {
const inputName = e.currentTarget.id;
const inputValue = e.currentTarget.value;
setInputData({
[inputName]: inputValue
} as {[key in keyof ILoginState]:ILoginState[key]})
}

antd form onsubmit

<Form onSubmit={handleSubmit.bind(this)}>

add window resizeLitener

const [contentHeight, setHeight]=useState(INTIAL_HEIGHT)
useEffect(()=>{
screenChange();
return () => removeListener()//回调销毁
},[contentHeight]) const screenChange = () => {
window.addEventListener("resize", handleResize)
} const removeListener = () => {
window.removeEventListener("resize", handleResize)
} handleResize =(e)=> {
setHeight(e.target.innerHeight-headerHeight-footerHeight)
}

react: typescript interface useState issue的更多相关文章

  1. react + typescript 学习

    react,前端三大框架之一,也是非常受开发者追捧的一门技术.而 typescript 是 javascript 的超集,主要特点是对 类型 的检查.二者的结合必然是趋势,不,已经是趋势了.react ...

  2. react: typescript project initialize

    Initialize the project create a folder project Now we’ll turn this folder into an npm package. npm i ...

  3. react typescript jest config (一)

    1. initialize project create a folder project Now we'll turn this folder into an npm package. npm in ...

  4. TypeScript Interface vs Types All In One

    TypeScript Interface vs Types All In One TypeScript https://www.typescriptlang.org/docs/handbook/adv ...

  5. React + Typescript领域初学者的常见问题和技巧

    React + Typescript领域初学者的常见问题和技巧 创建一个联合类型的常量 Key const NAME = { HOGE: "hoge", FUGA: "f ...

  6. 【每天学一点-04】使用脚手架搭建 React+TypeScript+umi.js+Antd 项目

    一.使用脚手架搭建项目框架 1.首先使用脚手架搭建React项目(React+TypeScript+Umi.js) 在控制台输入命令:yarn create @umijs/umi-app 2.引入An ...

  7. React typescript issue

    多个输入框发生变化时,setState: this.setState({[e.target.name]: e.target.value} as componentState)

  8. 使用react搭建组件库:react+typescript+storybook

    前期准备 1. 初始化项目 npx create-react-app react-components --template typescript 2. 安装依赖 使用哪种打包方案:webpack/r ...

  9. react+typescript报错集锦<持续更新>

    typescript报错集锦 错误:Import sources within a group must be alphabetized.tslint(ordered-imports) 原因:impo ...

随机推荐

  1. 深度学习中正则化技术概述(附Python代码)

    欢迎大家关注我们的网站和系列教程:http://www.tensorflownews.com/,学习更多的机器学习.深度学习的知识! 磐石 介绍 数据科学研究者们最常遇见的问题之一就是怎样避免过拟合. ...

  2. TensorFlow系列专题(五):BP算法原理

    欢迎大家关注我们的网站和系列教程:http://www.tensorflownews.com/ ,学习更多的机器学习.深度学习的知识! 一.反向传播算法简介 二.前馈计算的过程 第一层隐藏层的计算 第 ...

  3. dijskra算法(求正权图中最短路)

    思想:每次找到离原点最近的顶点,以这个点为中心扩展松弛,更新其余点到原点的最短路径. 注意:if(e[u][v]>x)e[u][v]=x; book[ ]数组标记最短路程的顶点集合 #inclu ...

  4. coding++:error 阿里云 Redis集群一直Waiting for the cluster to join....存在以下隐患

    1):Redis集群一直Waiting for the cluster to join... 再次进行连接时首先需要以下操作 1.使用redis desktop Manager连接所有节点 调出命令窗 ...

  5. 开源APP

    仿微信 https://github.com/zhengwenming/WeChat 电台韵律 https://github.com/DaMingShen 运动App https://github.c ...

  6. 一篇让你明白什么是浏览器BOM方法的笔记

    BOM Browser Object Model 浏览器对象模型 虚拟机 ,任何语言编辑的程序都需要一个虚拟机来执行.如果脱离这个环境就无法运行. 浏览器就是一种虚拟机.用来解析html语言 同一款浏 ...

  7. STL之map与pair与unordered_map常用函数详解

    STL之map与pair与unordered_map常用函数详解 一.map的概述 map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称 ...

  8. B. The Monster and the Squirrel

    B. The Monster and the Squirrel Ari the monster always wakes up very early with the first ray of the ...

  9. 配置一个mariadb数据库《二》

                                                             mariadb 配置一个数据库 案例4:配置一个数据库 4.1 问题 本例要求在虚拟机 ...

  10. win10无法使用VMwareWorkstation的解决办法

    最近(2019-10)国庆期间,微软更新了一次win10. 此次更新导致很多同学的Workstation pro不能用了. 主要的解决办法有一下几种: 卸载最新的系统更新包 在控制面板>> ...