useeffectasync
v0.0.1
Published
With `useEffectAsync` you can simply use async function ⛄. I.e.,
Downloads
2
Readme
🌈 This is a simple abstraction though it makes the asyn/await code look good with useEffectAsync instead of implementing something like
With useEffectAsync
you can simply use async function ⛄. I.e.,
import {useEffectAsync} from 'useeffectasync'
useEffectAsync(async () => {
// await .. blah .. blah
})
NOTE: You can definitely use dependencies array
as second parameters as we generally use useEffect hook. That is super cool with useEffectAsync
too.
Hmm, that was simple, but how does it look to use same example with bare useEffect
??
useEffect(() => {
async function myAsyncAwaitSugargedCode() {
// await .. blah .. blah
}
myAsyncAwaitSugargedCode()
})
Yeah, that's a little weirder. 🌊
CAUTION: The cleanup functionality isn't possbile to use with useEffectAsync
(I don't ever care about it though. ✨✨)
Thanks.