useState:使用与使用useReducer实现的使用状态相同的API进行React钩子

时间:2021-03-30 15:05:22
【文件属性】:
文件名称:useState:使用与使用useReducer实现的使用状态相同的API进行React钩子
文件大小:252KB
文件格式:ZIP
更新时间:2021-03-30 15:05:22
TypeScript useState 使用与useReducer实现的useState(加上一些扩展)相同的API进行React hook 为什么 useReducer按发出的顺序应用调度调用。 本机useState功能则没有。 用法 使用传统的useState API import { useState } from '@jeswr/use-state' function MyReactComponent ( ) { const [ counter , setCounter ] = useState ( 0 ) ; useEffect ( ( ) => { setCounter ( 1 ) ; } , [ ] ) return < div> { counter } < / div > } 使用附加modifier参数 import { useState } from '@je
【文件预览】:
useState-main
----package.json(2KB)
----__tests__()
--------main-test.ts(1KB)
----.eslintrc.json(545B)
----.github()
--------dependabot.yml(500B)
--------workflows()
----SECURITY.md(381B)
----LICENSE(1KB)
----package-lock.json(1.02MB)
----tsconfig.json(6KB)
----.gitignore(2KB)
----lib()
--------index.ts(688B)
----README.md(2KB)

网友评论