File tree 1 file changed +24
-14
lines changed
packages/core/components/DropZone
1 file changed +24
-14
lines changed Original file line number Diff line number Diff line change 1
- import { ReactNode , createContext , useCallback , useState } from "react" ;
1
+ import {
2
+ ReactNode ,
3
+ createContext ,
4
+ useCallback ,
5
+ useMemo ,
6
+ useState ,
7
+ } from "react" ;
2
8
import { Config , Data } from "../../types" ;
3
9
import { ItemSelector } from "../../lib/get-item" ;
4
10
@@ -100,21 +106,25 @@ export const DropZoneProvider = ({
100
106
[ setActiveZones , dispatch ]
101
107
) ;
102
108
109
+ const memoValue = useMemo (
110
+ ( ) =>
111
+ ( {
112
+ hoveringComponent,
113
+ setHoveringComponent,
114
+ registerZoneArea,
115
+ areasWithZones,
116
+ registerZone,
117
+ unregisterZone,
118
+ activeZones,
119
+ ...value ,
120
+ } as DropZoneContext ) ,
121
+ [ value , hoveringComponent , areasWithZones , activeZones ]
122
+ ) ;
123
+
103
124
return (
104
125
< >
105
- { value && (
106
- < dropZoneContext . Provider
107
- value = { {
108
- hoveringComponent,
109
- setHoveringComponent,
110
- registerZoneArea,
111
- areasWithZones,
112
- registerZone,
113
- unregisterZone,
114
- activeZones,
115
- ...value ,
116
- } }
117
- >
126
+ { memoValue && (
127
+ < dropZoneContext . Provider value = { memoValue } >
118
128
{ children }
119
129
</ dropZoneContext . Provider >
120
130
) }
You can’t perform that action at this time.
0 commit comments