Skip to content

Commit f4c853a

Browse files
added memo and callback on the mouseover function
1 parent 4942604 commit f4c853a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/components/design-library-list/design-library-list-item.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ import { Tooltip } from '~stackable/components'
1919
/**
2020
* WordPress dependencies.
2121
*/
22-
import { useState, useRef } from '@wordpress/element'
22+
import {
23+
useState, useRef, memo,
24+
} from '@wordpress/element'
2325
import { Dashicon, Spinner } from '@wordpress/components'
2426
import { __ } from '@wordpress/i18n'
2527

26-
const DesignLibraryListItem = props => {
28+
const DesignLibraryListItem = memo( props => {
2729
const {
2830
selectedTab,
2931
plan, label,
@@ -161,7 +163,7 @@ const DesignLibraryListItem = props => {
161163
</footer>
162164
</button>
163165
)
164-
}
166+
} )
165167

166168
DesignLibraryListItem.defaultProps = {
167169
designId: '',

src/components/design-library-list/use-auto-scroll.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { useRef, useEffect } from '@wordpress/element'
4+
import {
5+
useRef, useEffect, useCallback,
6+
} from '@wordpress/element'
57

68
const NOOP = () => {}
79

@@ -101,7 +103,7 @@ export const useAutoScroll = ( hostRef, shadowBodySizeRef, selectedTab ) => {
101103
}
102104
}
103105

104-
const onMouseDownImpl = () => {
106+
const onMouseDownImpl = useCallback( () => {
105107
// Stop auto-scrolling when user interacts
106108
isScrollingRef.current = false
107109
if ( animationFrameRef.current ) {
@@ -115,7 +117,7 @@ export const useAutoScroll = ( hostRef, shadowBodySizeRef, selectedTab ) => {
115117
delayTimeoutRef.current = null
116118
}
117119
scrollPositionRef.current = -1
118-
}
120+
}, [] )
119121

120122
// Cleanup any pending animation on unmount.
121123
useEffect( () => {

0 commit comments

Comments
 (0)