use-safe-effect
v1.0.2
Published
safe-effect-hook
Downloads
2
Readme
use-safe-effect
:running: Throw away the Promise
,Choose Async/Await
Installation
npm install use-safe-effect --save
Examples
import useSafeEffect from 'use-safe-effect'
useSafeEffect(async () => console.log('componentDidMount'), () => console.log('componentWillUnMount'), [])
import useSafeEffect from 'use-safe-effect'
import request from 'umi-request'
useSafeEffect(
async () => {
let res = await request(api)
console.log('componentDidMount')
},
() => {
console.log('componentWillUnMount')
},
[]
)