# nw-hooks

> lofter react hooks library

Latest version **0.1.3** (published 2025-12-08) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2025-12-08 |
| First published | 2021-02-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 245 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | jeekdong@gmail.com |
| Maintainers | jeekdong |

## Links

- npm: https://www.npmjs.com/package/nw-hooks
- npm.io page: https://npm.io/package/nw-hooks

## Dependencies (1)

- [dequal](https://npm.io/package/dequal.md) ^2.0.2

## Recent versions

- 0.1.3 (latest) — 2025-12-08
- 0.1.2 — 2023-05-30
- 0.1.1 — 2022-12-05
- 0.1.0 — 2022-12-05
- 0.0.6 — 2022-09-22
- 0.0.5 — 2022-05-05
- 0.0.4 — 2022-02-10
- 0.0.3 — 2021-04-01
- 0.0.2 — 2021-03-27
- 0.0.1 — 2021-02-19

## README

## 这是什么？

nw-hooks 是一组 React 自定义 Hooks 的集合，包括了业务开发中经常使用的基础&高级Hooks。

每个团队(个人)在项目开发中，随着业务的演进总会积累不少常用的自定义 Hooks ，重复的复制粘贴迁移既繁琐也不优雅。

更为重要的是 React Hooks 的使用有明显的上手门槛，有一个逐步上升的学习曲线

所以自定义 Hooks 并不像普通的工具函数，写完就万事大吉了，随着理解的深入往往会不断优化。

同时统一的自定义 Hooks 仓库有助于团队形成统一的书写风格，帮助初学者更快上手。

## Hooks 列表

| Hook | 描述 |
| --- | --- |
| usePersistFn | 持久化一个函数的引用 |
| useModal | 一个简化模态框使用的方案 |
| usePersistValue | 持久化一个值的引用，返回React.MutableRefObject 值 |
| useVirtualList | 虚拟列表逻辑实现 |
| useDynamicVirtualList | 不定高元素虚拟列表实现 |
| useThrottleFn | 函数节流 |
| useUpdateEffect | 仅在更新时执行副作用的useEffect |
| useDebounceState | 防抖版 useState |
| useDebounceFn | 函数防抖 |
| useScrollSwiper | 一个轮播组件的逻辑实现 |
| useDebugRenderCount | 显示状态变化所导致组件重复render的次数(仅在dev模式显示) |

## 辅助函数

| 名称 | 描述 |
| --- | --- |
| rem2Px | rem值转化为px值 |

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