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

lian-hooks

v1.0.4

Published

Made with create-react-library

Downloads

5

Readme

Constants

useEventListener

Kind: global constant
Description:: 在hooks中使用事件监听器

| Param | Type | Description | | --- | --- | --- | | target | * | dom对象或其ref引用 | | eventName | * | 事件名称 | | listener | * | 事件监听器 |

useSize ⇒ Object

Kind: global constant
Returns: Object - {width, height}
Description:: 监听元素大小变化

| Param | Description | | --- | --- | | ref | 元素ref引用 |

useMouse ⇒ *

Kind: global constant
Returns: * - 鼠标位置信息
Description:: 获取鼠标位置信息

useDrag ⇒ function

Kind: global constant
Returns: function - 一个获取拖拽属性的函数,入参为拖拽传输的数据
Description:: 获取可以被拖拽的元素属性

| Param | Type | Description | | --- | --- | --- | | config | Object | 拖拽开始执行的函数, 拖拽结束执行的函数 |

useDrop ⇒ Object

Kind: global constant
Returns: Object - 释放元素属性
Description:: 获取接收被拖拽内容的元素的属性

useDragableBox ⇒ Object

Kind: global constant
Returns: Object - 包含宽度和拖拽状态的对象
Description:: 拉伸容器

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.defaultWidth | Number | 默认宽度 | | options.minWidth | Number | 最小宽度 | | options.maxWidth | Number | 最大宽度 | | options.target | * | 被拉伸的容器 | | options.siderTarget | * | 用于拉伸的边缘 |

useMutation ⇒ Array

Kind: global constant
Returns: Array - 异步方法和状态信息
Description:: 异步方法的简单封装,处理请求的loading状态

| Param | Type | Description | | --- | --- | --- | | method | function | 异步方法 | | [initialData] | Object | 初始数据 |

useRequest

Kind: global constant
Description:: 请求方法的简单封装,处理请求的loading状态

| Param | Type | Description | | --- | --- | --- | | options | Object | 配置 | | options.method | function | 请求方法 | | [options.defaultParams] | Object | 默认参数 | | [options.necessaryParams] | Object | 必要参数 | | [options.ready] | Boolean | === true时发起请求,默认值为true | | [options.initialData] | * | 初始数据 | | [options.rest] | Array | 请求方法额外参数, onError事件等options可以通过这个参数传递 |

usePagination ⇒ *

Kind: global constant
Returns: * - pagination
Description:: 处理分页状态的hooks

| Param | Type | Description | | --- | --- | --- | | config | Object | | | config.defaultPageSize | * | 默认分页大小 | | config.total | * | 总数据条数 |

useTable

Kind: global constant
Description:: 封装方便antd table使用的hooks

| Param | Type | Default | Description | | --- | --- | --- | --- | | options | Object | | 配置信息 | | options.method | function | | 请求方法 | | [options.defaultPageSize] | Number | 10 | 默认分页大小 | | [options.necessaryParams] | Object | | 必要请求参数 | | [options.rowSelection] | Object | Boolean | | 选择功能配置, 传true使用默认 | | [options.formatter] | function | | 请求结果数据转换函数, 返回{total, dataSource} |

useInterval ⇒ *

Kind: global constant
Returns: * - clearInterval
Description:: setInterval的hooks实现

| Param | Type | Description | | --- | --- | --- | | func | function | 要执行的函数 | | interval | Number | 执行间隔 | | deps | Array | 依赖项 |

useTimeout ⇒ function

setTimeout的hooks实现

Kind: global constant
Returns: function - clearTimeout

| Param | Type | Description | | --- | --- | --- | | func | function | 要执行的函数 | | timeout | Number | 执行间隔 | | deps | Array | 依赖项 |

useThrottledValue ⇒ *

Kind: global constant
Returns: * - 放缓变化的值
Description:: 放缓获取value的速率(节流)

| Param | Type | Description | | --- | --- | --- | | value | * | 要节流的值 | | wait | Number | 节流时间间隔 |

useDebouncedValue ⇒ *

Kind: global constant
Returns: * - 处理后的值
Description:: 合并一定时间内多次获取value的值(防抖)

| Param | Type | Description | | --- | --- | --- | | value | * | 要节流的值 | | wait | Number | 节流时间间隔 |

useShouldUpdateEffect

Kind: global constant
Description:: 自定义useEffect的更新逻辑

| Param | Type | Description | | --- | --- | --- | | effect | EffectCallback | 作用 | | deps | Array | 依赖 | | shouldUpdate | function | 是否执行作用,返回true执行effect |

useCustomCompareEffect

Kind: global constant
Description:: 自定义useEffect的依赖比较逻辑

| Param | Type | Description | | --- | --- | --- | | effect | EffectCallback | 作用 | | deps | Array | 依赖 | | compare | function | 自定义比较函数 |

useDeepCompareEffect

Kind: global constant
Description:: 使用深比较的useEffect

| Param | Type | Description | | --- | --- | --- | | effect | EffectCallback | 作用 | | deps | Array | 依赖 |

usePrevious ⇒ *

Kind: global constant
Returns: * - 前一个值
Description:: 获取上一个值

| Param | Type | Description | | --- | --- | --- | | state | * | 当前值 | | [compare] | function | 比较函数, 返回true时更新上一个值,默认每次渲染都更新 |

useUpdateEffect

Kind: global constant
Description:: 组件更新时执行的事件

| Param | Type | Description | | --- | --- | --- | | fn | function | 要执行的函数 | | deps | Array | 依赖项 |

useUnmount

Kind: global constant
Description:: 组件卸载时执行的操作

| Param | Type | Description | | --- | --- | --- | | fn | function | 操作函数 |

useIsUnmounted ⇒ Boolean

Kind: global constant
Returns: Boolean - : 组件是否已卸载
Description:: 获取组件卸载状态

useIsMounted ⇒ Boolean

Kind: global constant
Returns: Boolean - : 组件是否已挂载
Description:: 获取组件卸载状态

useLog

Kind: global constant
Description:: 值变化时打印

| Param | Type | Description | | --- | --- | --- | | args | array | 打印内容 |

useFlag ⇒ Object

真假值状态封装

Kind: global constant

| Param | Type | Description | | --- | --- | --- | | initialFlag | * | 初始状态 |

useModalAction ⇒ Object

弹出框状态封装

Kind: global constant

| Param | Type | Description | | --- | --- | --- | | [initialProps] | Object | modal属性初始值 |