# cd-hooks

> Some react hooks

Latest version **0.0.1-beta.9** (published 2022-01-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install cd-hooks
pnpm add cd-hooks
yarn add cd-hooks
bun add cd-hooks
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1-beta.9 |
| Published | 2022-01-26 |
| First published | 2021-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | YutLee |
| Maintainers | yutlee |
| Keywords | hooks, react, react-hooks |

## Links

- npm: https://www.npmjs.com/package/cd-hooks
- Repository: https://github.com/YutLee/cd-hooks
- npm.io page: https://npm.io/package/cd-hooks

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.1-beta.9 (latest) — 2022-01-26
- 0.0.1-beta.8 — 2022-01-26
- 0.0.1-beta.7 — 2021-12-21
- 0.0.1-beta.6 — 2021-12-21
- 0.0.1-beta.5 — 2021-12-21
- 0.0.1-beta.4 — 2021-12-21
- 0.0.1-beta.3 — 2021-12-15
- 0.0.1-beta.2 — 2021-11-24
- 0.0.1-beta.1 — 2021-11-24

## README

# cd-hooks
Some react hooks

## useMount
```
useMount(() => {
  console.log('mount')
})
```

## useUnmount
```
useUnmount(() => {
  console.log('unmount')
})
```

## useMountEffect
```
useMountEffect(() => {
  console.log('mount')
}, () => {
  console.log('unmount')
})
```

## useFetch
```
const one = useFetch(getData) // 单个请求
const multi = useFetch([getData, getUsersDefunkt]) // 多个请求
const parallel = useFetch([getData, getUsersDefunkt], { parallel: true }) // 并行请求
```

### API
```
const {
  loading: boolean,
  data?: any,
  error?: Error,
  params: any,
  run: (...params: any) => void
} = useFetch(
  service: (...args: any) => Promise<TData>,
  {
    auto?: boolean,
    parallel?: boolean,
    params?: any,
    onBefore?: (params: any) => void,
    onSuccess?: (data: any, params: any) => void,
    onError?: (err: Error, params: any) => void,
    onFinally?: (params: any, data?: any, err?: Error) => void
  }
)
```

## useScroll
```
useScroll(document, (position) => {
  console.log(position)
  return true
})
```

---
_Source: https://npm.io/package/cd-hooks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
