npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@armin4fun/use-react-hooks

v0.0.5

Published

A React Hooks library build by rollup and typescript.

Readme

React Hooks Library 🎣

一个高性能、类型安全的 React Hooks 集合,为你的 React 应用提供常用的工具函数。

特性

  • 🚀 完全 TypeScript - 完整的类型定义
  • 📦 轻量级 - 极小的体积,零依赖
  • 🎯 高性能 - 优化渲染,避免不必要的重渲染
  • 🔧 实用性强 - 精选日常开发中最需要的 Hooks
  • 🌳 Tree Shakable - 只打包你使用的代码

Hooks 列表

🎯 State 管理

useBoolean

布尔值状态管理,提供切换、设置 true/false 的方法。

useLatest

返回一个 ref,其 current 值始终是最新的值,避免闭包问题。

usePrevious

获取上一次渲染的值,用于比较前后状态变化。

useRafState

使用 requestAnimationFrame 来更新状态,避免频繁渲染造成的性能问题。

⏰ 定时器 & 倒计时

useCountdown

倒计时 Hook,支持开始、暂停、重置等操作。

🖱️ DOM 交互

useClickAway

点击元素外部时触发回调,常用于下拉菜单、模态框等场景。

useEventListener

便捷地添加和移除事件监听器,支持多种事件类型。

useFullscreen

控制元素全屏显示,支持进入、退出、切换全屏状态。

useHover

检测元素是否被鼠标悬停,返回悬停状态和 ref。

📐 元素尺寸与观察

useElementSize

获取元素的尺寸(width/height),响应尺寸变化。

useResizeObserver

使用 ResizeObserver API 监听元素尺寸变化。

useInViewport

检测元素是否在视口内可见,返回可见状态和比例。

useIntersectionObserver

使用 IntersectionObserver API 监听元素交叉状态。

🖼️ 资源处理

useImage

图片加载状态管理,返回加载中、错误、成功等状态。

🎯 效果优化

useEffectWithTarget

支持 target 元素的 useEffect,自动处理 DOM 引用和清理。

安装

# npm
npm install @armin4fun/use-react-hooks

# yarn
yarn add @armin4fun/use-react-hooks

# pnpm
pnpm add @armin4fun/use-react-hooks