Catalog npm
Back to packageRELEASE DETAILS

0.0.1

npm

5e-hooks

#### useResetAction

Published12 Aug 2020
Direct dependencies16
Transitive dependenciesNot calculated

README

Current package documentation

自定义hook库

useResetAction

当页面离开时触发

无返回值

const resetState = () => {
    setAge(0)
    setValue({})
}

useResetAction(resetState)

// ---> WillUnmount

useMount

// 初始化逻辑
const initParams = () => {
  //xxxx
}

useMount(initParams) // 首次进入页面的时候执行一次, 无副作用, 内部禁止掉了

ps. 隔离副作用 hook ---> didMount

useDebounce

指定函数内触发

// run: 执行 cancel: 取消 fn 是你需要防抖的函数  options是触发条件
// 一般cancel 比较少去使用

...
const options = {
  isImmediate: true,       // 是否是立即执行
  delayTime: 1000          // 延迟 or 执行
}
const [run, cancel] = useDebounce(fn, options)
const [value, setValue] = useState('')

// 频繁触发的逻辑
const requestStorage = async () => {
  const res = await api.saveValue(params)
  ...  
}

const changeValue = (e: any) => {
  setValue(e.target.value)
  run(requestStorage)
}

<Input onChange={changeValue} value={value} />

...

useThrottle

const [run] = useThrottle(fn, {delayTime: 1000})

useSessionStorage

const [value, saveValue] = useSessionStorage('jb')
...

useOnresize

const width = useOnResize(time)

time: 内部集成了防抖逻辑, 是延迟输出的时间

useLocalStorage

const [value, saveValue] = useLocalStorage('jb')
...

TODO

useToggle

github的地址

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 16

Native requirements
16 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@types/react
Environment
{
  "local_name": "@types/react",
  "alias": false,
  "peer_metadata": null
}
^16.9.38runtime
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
^16.13.1runtime
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^3.9.5runtime
@storybook/addon-info
Environment
{
  "local_name": "@storybook/addon-info",
  "alias": false,
  "peer_metadata": null
}
^5.3.19development
@storybook/react
Environment
{
  "local_name": "@storybook/react",
  "alias": false,
  "peer_metadata": null
}
^5.3.19development
@testing-library/react-hooks
Environment
{
  "local_name": "@testing-library/react-hooks",
  "alias": false,
  "peer_metadata": null
}
^3.3.0development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^26.0.0development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^7.3.1development
eslint-config-5e
Environment
{
  "local_name": "eslint-config-5e",
  "alias": false,
  "peer_metadata": null
}
^0.0.7development
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^26.1.0development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.0.5development
react-docgen-typescript-loader
Environment
{
  "local_name": "react-docgen-typescript-loader",
  "alias": false,
  "peer_metadata": null
}
^3.7.2development
react-dom
Environment
{
  "local_name": "react-dom",
  "alias": false,
  "peer_metadata": null
}
^16.13.1development
react-test-renderer
Environment
{
  "local_name": "react-test-renderer",
  "alias": false,
  "peer_metadata": null
}
^16.13.1development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^26.1.1development
ts-loader
Environment
{
  "local_name": "ts-loader",
  "alias": false,
  "peer_metadata": null
}
^7.0.5development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-IXG3kwFpLihNl+VhPM01SSoXdH93MoGepGgQc7YaSvbafgwVLWLr3qcoWF80gh8en+qO60sAmE5Y70dkDsL0zg==",
  "shasum": "7be803ce47b39604548ece29fde683dd03cde77f",
  "tarball": "https://registry.npmjs.org/5e-hooks/-/5e-hooks-0.0.1.tgz",
  "fileCount": 18,
  "unpackedSize": 8457,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfM4haCRA9TVsSAnZWagAAIykP/RAhPl7SJPMooVoMdwVf\noFRjoswU9BQPGuZJPkNi51+Z+oyMR4PAacWBESvzOeaOK7rrBfwykx7qwErx\n0vTt9ueX8e7BhnPzhC9d/r50ICniKMIyPRZpG+8m7YCnwumNltm+t5XAdpn/\nWBWSlfUcu9g0I/ghR1od20bmFBvgsRVJ2Z8A2sTxtWYEOhbSrSvVtJBuuc7U\nObWb0ITPqoWr7P13NcHhl/m8X+TOTPvs2yXZOioPrnwSQNOLsM/s7/rtc+6c\nzsKDsRRvPun2JJ6RkWj3+uyeJcRlDprgVk6DCBPHFJVE9Uke9uR1qTZrRT1y\n8ZKRY/7UkmRddTz4WvCsV3Md28bAzdQse7b6aGveA2i5O78mJXiITv2Vh+I6\n/lfsaqwor3syTRWFXazLe59UDYeSe9LvGYJgNLKeRAZGf225ll2Vd8EIUmzp\nNi1SBpU13arnWPVxNxsJj7Hc/QkrOyFjDensP2aauREJL+B+8Zw6cBVV8zjA\nKDeavQntq7u0xqIdxFxPsMrtsqeLdC2S2iiKPqmRqKdboqyLo6c/j/LoslST\nmXSnt3l3IyD31emwcE4wR99UV8FmYeV3QpVnGifcYMt7S3VSeGR60ZkOnqYN\njX0NGRxA/8R1mURb7Q3wIrnHDMggVj1AtV8+m0HsBeiF1PahA9t5wVSPKKdo\nu2xm\r\n=fzyL\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEQCIAUTQLJasppjm9UTUuNiFBQ95CW5rnqxDyQlIvUkCzs0AiAfaAk0OyhIql2lWKI2YDb8XyfgRqtu5Ym860XTWHrXDg=="
    }
  ]
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:32 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:ecd4fa34f2529299ffd25e4948eb749e14a45a0a4efbe7a8315180988741bc3f

Other collected versions

0.0.218 AugView all collected versions →