powerful-hooks
TypeScript icon, indicating that this package has built-in type declarations

1.1.19 • Public • Published

powerful-hooks

NPM version NPM downloads

More powerful React hooks

It's a state hook that can remember your initial value.

// 可重置的state。
import { useMemoState } from 'powerful-hooks';

const [state, setState, resetState] = useMemoState(initValue);
// 如同在类组件中的setState使用方式,同样支持重置。
import { useSetState } from 'powerful-hooks';

const [state, setState, resetState] = useSetState(initValue);
// fetch请求。
import { useGet, usePost, usePut, useDelete } from 'powerful-hooks';

const { data, loading, run } = useGet({
  url: '/api/url',
  data: { key: 'value' },
  headers: { key: 'value' },
  handler: (responens) => {},
  manual: true,
});
// 获取url中的query参数。
import { useUrlQuery } from 'powerful-hooks';

const { get, getAll } = useUrlQuery();
get('key');
getAll();
// 防抖函数
import { useDebounceFn } from 'powerful-hooks';

const debounceFn = useDebounceFn(fn, wait);
// 节流函数
import { useThrottleFn } from 'powerful-hooks';

const throttleFn = useThrottleFn(fn, wait);
// 防抖state
import { useDebounceState } from 'powerful-hooks';

const [state, setState] = useDebounceState(initialValue, wait);
// 节流state
import { useThrottleState } from 'powerful-hooks';

const [state, setState] = useThrottleState(initialValue, wait);
// float浮点数运算
import { useFloat } from 'powerful-hooks';
const { add, subtract, multiply, divide } = useFloat;

add(0.1, 0.2, 0.3);       // 0.6
subtract(0.3, 0.2);       // 0.1
multiply(0.3,0.77);       // 0.231
divide(0.3, 3);           // 0.1

Package Sidebar

Install

npm i powerful-hooks

Weekly Downloads

4

Version

1.1.19

License

MIT

Unpacked Size

75.4 kB

Total Files

41

Last publish

Collaborators

  • findzsh