use-safe-effect
🏃 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')
},
[]
)