1.0.1 • Published 4 years ago

react-loading-state v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

React Loading State

Loading state for react

Example

import {useCallback} from 'react'
import useLoading from './index'

async function fetch(): Promise<string> {
  return new Promise<string>(resolve =>
    setTimeout(() => resolve(
      new Date().toLocaleDateString()),
      Math.random() * 10000
    )
  )
}

export default function App() {
  const { loading, load, loaded } = useLoading()

  const doFetch = useCallback(() => {
    const loadingKey = load()
    fetch().then(res => {
      console.log(res)
    }).finally(() => {
      loaded(loadingKey)
    })
  }, [load, loaded])

  return <Button loading={loading} onClick={doFetch}>Fetch</Button>
}
1.0.1

4 years ago

1.0.0

4 years ago

0.9.6

4 years ago

0.9.5

4 years ago

0.9.4

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago