giao-hook

解决useEffect闭包陷阱问题,畅快拿到最新变更的state

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
giao-hook
101.0.34 months ago4 months agoMinified + gzip package size for giao-hook in KB

Readme

usage

```jsx import React, { useEffect, useState } from 'react' import { useAsyncGetState } from 'giao-hook' function App() { const count1, setCount1, getCount1 = useAsyncGetState(10) const count2, setCount2 = useState(0) async function changeCount1() {
await setCount1(count1 + 1)
} function changeCount2() {
setCount2(getCount1() * 10)
} useEffect(() => {
changeCount1()
changeCount2()
}, ) return (
<div> 
<h2>count1: { count1 }</h2>
<h2>count2: { count2 }</h2> 
</div>
); } export default App; ```