Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Replace custom useThrottle with useThrottledCallback from use-debounc…
Browse files Browse the repository at this point in the history
…e package
  • Loading branch information
mikejolley committed Apr 21, 2023
1 parent 13ec113 commit 6541612
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 41 deletions.
8 changes: 2 additions & 6 deletions assets/js/blocks/featured-items/constrained-resizable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
import classnames from 'classnames';
import { useState } from '@wordpress/element';
import { ResizableBox } from '@wordpress/components';

/**
* Internal dependencies
*/
import { useThrottle } from '../../utils/useThrottle';
import { useThrottledCallback } from 'use-debounce';

type ResizeCallback = Exclude< ResizableBox.Props[ 'onResize' ], undefined >;

Expand All @@ -22,7 +18,7 @@ export const ConstrainedResizable = ( {
const classNames = classnames( className, {
'is-resizing': isResizing,
} );
const throttledResize = useThrottle< ResizeCallback >(
const throttledResize = useThrottledCallback< ResizeCallback >(
( event, direction, elt, _delta ) => {
if ( ! isResizing ) setIsResizing( true );
onResize?.( event, direction, elt, _delta );
Expand Down
1 change: 0 additions & 1 deletion assets/js/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ export * from './filters';
export * from './notices';
export * from './products';
export * from './shared-attributes';
export * from './useThrottle';
export * from './sanitize-html';
34 changes: 0 additions & 34 deletions assets/js/utils/useThrottle.ts

This file was deleted.

0 comments on commit 6541612

Please sign in to comment.