use-safe-effect
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

use-safe-effect

npm version license


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

Readme

Keywords

Package Sidebar

Install

npm i use-safe-effect

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

3.74 kB

Total Files

6

Last publish

Collaborators

  • zhusijia