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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nw-hooks

v0.1.2

Published

lofter react hooks library

Downloads

25

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值 |