# @etu/hooks

> hooks of etu

Latest version **1.3.2** (published 2019-12-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install @etu/hooks
pnpm add @etu/hooks
yarn add @etu/hooks
bun add @etu/hooks
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2019-12-09 |
| First published | 2019-11-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 48.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | handy |
| Maintainers | handylee, hazeflame, invalidtoken |

## Links

- npm: https://www.npmjs.com/package/@etu/hooks
- Repository: https://github.com/etu-front/etu-hooks
- Homepage: https://github.com/etu-front/etu-hooks#readme
- Issues: https://github.com/etu-front/etu-hooks/issues
- npm.io page: https://npm.io/package/@etu/hooks

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [nprogress](https://npm.io/package/nprogress.md) ^0.2.0

## Recent versions

- 1.3.2 (latest) — 2019-12-09
- 1.3.1 — 2019-12-09
- 1.3.0 — 2019-12-09
- 1.2.2 — 2019-11-29
- 1.2.1 — 2019-11-22
- 1.2.0 — 2019-11-20
- 1.1.0 — 2019-11-19
- 1.0.4 — 2019-11-19
- 1.0.3 — 2019-11-19
- 1.0.2 — 2019-11-19
- 1.0.1 — 2019-11-18
- 1.0.0 — 2019-11-18

## README

# Etu Hooks Lib

> 常用 hooks 库

## Usage
- useTitle
- useDataLoader
- useWindowSize

1. useTtitle
```tsx
import { useTitle } from '@etu/hooks'

// Component
  // 第一种用法
  useTitle('页面标题', true)

  // 第二种用法 jsx 中
  const { DocumentTitle } = useTitle
  <DocumentTitle title="页面标题2" useReset />
```

2. useDataLoader
```tsx
import request from '@/utils/request'
import { useDataLoader } from '@etu/hooks'

interface IUser {
  id: number
  name: string
}
interface UserListReturn {
  results: IUser[]
  pageInfo: { page: number, pageSize: number, count: number }
}
// Component
const { data, loading, error, update } = useDataLoader(getUserList, 1, 20)
  if (error) return <div>出错啦</div>
  if (loading) return <div>loading...</div>

  return (
    <div>
      <ul>
        {data.results.map(u => <li key={u.id}>{u.name}</li>)}
      </ul>
      <button type="button" onClick={() => update({ results: [] })}>清空</button>
    </div>
  )
```

## 开发
```bash
$ git clone git@github.com:etu-front/etu-hooks.git
$ cd etu-hooks
$ npm install
$ npm run dev
# visit http://localhost:3000
```
## 发布
```bash
$ npm run pub
```
## Git 提交 emoji

- 🐛 🚑 修复bug
- ✨ 新功能
- 🔥 删除代码或文件
- 💩 需要提升的 shit 代码
- 🎁 新增组件
- ️️♻️ 🔨 重构
- 🚀 部署或提升性能
- 💄 🎨 UI 样式 css style
- 📝 文档或注释
- 🌐 i18n
- ✏️ 修复 typo 错误
- ➕ 增加依赖包
- 📦 更新打包
- 🎉 初始化

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