useeffectasync

0.0.1 • Public • Published

🌈 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.

Readme

Keywords

none

Package Sidebar

Install

npm i useeffectasync

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

1.29 kB

Total Files

5

Last publish

Collaborators

  • sahilrajput03