1.0.1 • Published 2 years ago

use-f v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago
import { useF, useE } from 'use-f';

Replace useEffect with useF for functions without clean-up

useEffect(() => {
    // do something with arg1 and arg2
}, [arg1, arg2])

useF(arg1, arg2, () => {
    // do something with arg1 and arg2
})
useEffect(() => {
    doSomethingWithArg3()
}, [arg3])

useF(arg3, doSomethingWithArg3)

Or, replace with useE to keep clean-up

useE(arg4, () => {
    // do something with arg4 that requires clean-up
    return () => {
      // do clean-up
    }
})