@@ -24,7 +24,7 @@ import {
24
24
DEFAULT_GRID_COLUMNS ,
25
25
DEFAULT_ROW_HEIGHT ,
26
26
} from "layout/calculateUtils" ;
27
- import _ from "lodash" ;
27
+ import _ , { isEqual } from "lodash" ;
28
28
import {
29
29
ActionExtraInfo ,
30
30
changeChildAction ,
@@ -313,7 +313,7 @@ const ItemWrapper = styled.div<{ $disableInteract?: boolean }>`
313
313
pointer-events: ${ ( props ) => ( props . $disableInteract ? "none" : "unset" ) } ;
314
314
` ;
315
315
316
- const GridItemWrapper = React . forwardRef (
316
+ const GridItemWrapper = React . memo ( React . forwardRef (
317
317
(
318
318
props : React . PropsWithChildren < HTMLAttributes < HTMLDivElement > > ,
319
319
ref : React . ForwardedRef < HTMLDivElement >
@@ -326,11 +326,11 @@ const GridItemWrapper = React.forwardRef(
326
326
</ ItemWrapper >
327
327
) ;
328
328
}
329
- ) ;
329
+ ) ) ;
330
330
331
331
type GirdItemViewRecord = Record < string , GridItem > ;
332
332
333
- export function InnerGrid ( props : ViewPropsWithSelect ) {
333
+ export const InnerGrid = React . memo ( ( props : ViewPropsWithSelect ) => {
334
334
const {
335
335
positionParams,
336
336
rowCount = Infinity ,
@@ -348,11 +348,13 @@ export function InnerGrid(props: ViewPropsWithSelect) {
348
348
349
349
// Falk: TODO: Here we can define the inner grid columns dynamically
350
350
//Added By Aqib Mirza
351
- const defaultGrid =
352
- horizontalGridCells ||
351
+ const defaultGrid = useMemo ( ( ) => {
352
+ return horizontalGridCells ||
353
353
currentTheme ?. gridColumns ||
354
354
defaultTheme ?. gridColumns ||
355
355
"12" ;
356
+ } , [ horizontalGridCells , currentTheme ?. gridColumns , defaultTheme ?. gridColumns ] ) ;
357
+
356
358
/////////////////////
357
359
const isDroppable =
358
360
useContext ( IsDroppable ) && ( _ . isNil ( props . isDroppable ) || props . isDroppable ) && ! readOnly ;
@@ -385,7 +387,7 @@ export function InnerGrid(props: ViewPropsWithSelect) {
385
387
386
388
const canAddSelect = useMemo (
387
389
( ) => _ . size ( containerSelectNames ) === _ . size ( editorState . selectedCompNames ) ,
388
- [ containerSelectNames , editorState ]
390
+ [ containerSelectNames , editorState . selectedCompNames ]
389
391
) ;
390
392
391
393
const dispatchPositionParamsTimerRef = useRef ( 0 ) ;
@@ -432,16 +434,21 @@ export function InnerGrid(props: ViewPropsWithSelect) {
432
434
onPositionParamsChange ,
433
435
onRowCountChange ,
434
436
positionParams ,
435
- props ,
437
+ props . dispatch ,
438
+ props . containerPadding ,
436
439
]
437
440
) ;
438
441
const setSelectedNames = useCallback (
439
442
( names : Set < string > ) => {
440
443
editorState . setSelectedCompNames ( names ) ;
441
444
} ,
442
- [ editorState ]
445
+ [ editorState . setSelectedCompNames ]
443
446
) ;
444
- const { width, ref } = useResizeDetector ( { onResize, handleHeight : isRowCountLocked } ) ;
447
+
448
+ const { width, ref } = useResizeDetector ( {
449
+ onResize,
450
+ handleHeight : isRowCountLocked ,
451
+ } ) ;
445
452
446
453
const itemViewRef = useRef < GirdItemViewRecord > ( { } ) ;
447
454
const itemViews = useMemo ( ( ) => {
@@ -464,9 +471,10 @@ export function InnerGrid(props: ViewPropsWithSelect) {
464
471
const clickItem = useCallback (
465
472
(
466
473
e : React . MouseEvent < HTMLDivElement ,
467
- globalThis . MouseEvent > , name : string
474
+ globalThis . MouseEvent > ,
475
+ name : string ,
468
476
) => selectItem ( e , name , canAddSelect , containerSelectNames , setSelectedNames ) ,
469
- [ canAddSelect , containerSelectNames , setSelectedNames ]
477
+ [ selectItem , canAddSelect , containerSelectNames , setSelectedNames ]
470
478
) ;
471
479
472
480
useEffect ( ( ) => {
@@ -555,7 +563,9 @@ export function InnerGrid(props: ViewPropsWithSelect) {
555
563
{ itemViews }
556
564
</ ReactGridLayout >
557
565
) ;
558
- }
566
+ } , ( prevProps , newProps ) => {
567
+ return isEqual ( prevProps , newProps ) ;
568
+ } ) ;
559
569
560
570
function selectItem (
561
571
e : MouseEvent < HTMLDivElement > ,
0 commit comments