Elements/Button: replace throttle with useThrottledCallback

This commit is contained in:
Chika 2022-09-18 13:29:36 +03:00
parent f57720bf47
commit 253ca05373

View File

@ -1,7 +1,7 @@
import { Button as AntButton } from 'antd';
import type { BaseButtonProps } from 'antd/lib/button/button';
import { throttle } from 'radash/dist/curry';
import type { FC } from 'react';
import { useThrottledCallback } from 'use-debounce';
import type { BaseElementProps } from './types';
type ElementProps = {
@ -17,12 +17,9 @@ export default (function Button({
text,
...props
}: BaseElementProps<never> & ElementProps) {
const throttledAction = throttle(
{
interval: 1200,
},
action
);
const throttledAction = useThrottledCallback(action, 1200, {
trailing: false,
});
return (
<AntButton