0.2.4 • Published 2 years ago

@fortissimo/hook v0.2.4

Weekly downloads
-
License
Apache
Repository
github
Last release
2 years ago

@nebula/hook

react hooks函数库

npm i @nebula/hook

使用示例

import React, { useState } from 'react';
import { useWatch } from '@tb-util/hook';

export function Main() {
  const [data, setData] = useState(0)
  useWatch(() => {}, data);
  return (
    <div onclick={() => {
        setData(data + 1)
      }}
    >
      {data}
    </div>
  );
}

API

hook名功能返回值备注
useMount在组件挂载后执行的一次性操作void
useWatch在被监听数据变化后执行的操作,可对比前后数据void
useInitStore初始化storeStore
useInitSimpleStore初始化简易storeSimpleStore
useCustomEventTarget生成或获取自定义事件中心CustomEventTarget
useCustomEventListener给自定义事件中心监听事件void
useEventTarget生成或获取事件中心EventTarget
useEventListener给事件中心监听事件void
useStorageMessage监听本地存储发送消息事件void
0.2.4

2 years ago

0.2.1

2 years ago

0.2.1-0

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago