Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lian-hooks

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lian-hooks

Made with create-react-library

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Constants

useEventListener
useSizeObject
useMouse*
useDragfunction
useDropObject
useDragableBoxObject
useMutationArray
useRequest
usePagination*
useTable
useInterval*
useTimeoutfunction

setTimeout的hooks实现

useThrottledValue*
useDebouncedValue*
useShouldUpdateEffect
useCustomCompareEffect
useDeepCompareEffect
usePrevious*
useUpdateEffect
useUnmount
useIsUnmountedBoolean
useIsMountedBoolean
useLog
useFlagObject

真假值状态封装

useModalActionObject

弹出框状态封装

useEventListener

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

ParamTypeDescription
target*dom对象或其ref引用
eventName*事件名称
listener*事件监听器

useSize ⇒ Object

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

ParamDescription
ref元素ref引用

useMouse ⇒ *

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

useDrag ⇒ function

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

ParamTypeDescription
configObject拖拽开始执行的函数, 拖拽结束执行的函数

useDrop ⇒ Object

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

useDragableBox ⇒ Object

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

ParamTypeDescription
optionsObject
options.defaultWidthNumber默认宽度
options.minWidthNumber最小宽度
options.maxWidthNumber最大宽度
options.target*被拉伸的容器
options.siderTarget*用于拉伸的边缘

useMutation ⇒ Array

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

ParamTypeDescription
methodfunction异步方法
[initialData]Object初始数据

useRequest

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

ParamTypeDescription
optionsObject配置
options.methodfunction请求方法
[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

ParamTypeDescription
configObject
config.defaultPageSize*默认分页大小
config.total*总数据条数

useTable

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

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

useInterval ⇒ *

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

ParamTypeDescription
funcfunction要执行的函数
intervalNumber执行间隔
depsArray依赖项

useTimeout ⇒ function

setTimeout的hooks实现

Kind: global constant
Returns: function - clearTimeout

ParamTypeDescription
funcfunction要执行的函数
timeoutNumber执行间隔
depsArray依赖项

useThrottledValue ⇒ *

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

ParamTypeDescription
value*要节流的值
waitNumber节流时间间隔

useDebouncedValue ⇒ *

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

ParamTypeDescription
value*要节流的值
waitNumber节流时间间隔

useShouldUpdateEffect

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

ParamTypeDescription
effectEffectCallback作用
depsArray依赖
shouldUpdatefunction是否执行作用,返回true执行effect

useCustomCompareEffect

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

ParamTypeDescription
effectEffectCallback作用
depsArray依赖
comparefunction自定义比较函数

useDeepCompareEffect

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

ParamTypeDescription
effectEffectCallback作用
depsArray依赖

usePrevious ⇒ *

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

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

useUpdateEffect

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

ParamTypeDescription
fnfunction要执行的函数
depsArray依赖项

useUnmount

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

ParamTypeDescription
fnfunction操作函数

useIsUnmounted ⇒ Boolean

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

useIsMounted ⇒ Boolean

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

useLog

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

ParamTypeDescription
argsarray打印内容

useFlag ⇒ Object

真假值状态封装

Kind: global constant

ParamTypeDescription
initialFlag*初始状态

useModalAction ⇒ Object

弹出框状态封装

Kind: global constant

ParamTypeDescription
[initialProps]Objectmodal属性初始值

FAQs

Package last updated on 26 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc