1.0.2 • Published 4 years ago
use-safe-effect v1.0.2
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')
},
[]
)