@@ -80,6 +80,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
8080 const [ , setForceUpdateToken ] = useState ( Symbol ( 'initial force update token' ) ) ;
8181 const removalLocker = useContext ( RemovalLockerContext ) ;
8282 const restoreParentLink = useContext ( RestoreTreeContext ) ;
83+ const restoreParentLinkRef = useRef ( restoreParentLink ) ;
8384 const instance = useRef < any > ( ) ;
8485 const element = useRef < HTMLDivElement > ( ) ;
8586 const portalContainer = useRef < HTMLElement | null > ( ) ;
@@ -127,15 +128,10 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
127128 childElementsDetached . current = false ;
128129 }
129130
130- if ( restoreParentLink && element . current && ! element . current . isConnected ) {
131- restoreParentLink ( ) ;
131+ if ( restoreParentLinkRef . current && element . current && ! element . current . isConnected ) {
132+ restoreParentLinkRef . current ( ) ;
132133 }
133- } , [
134- childNodes . current ,
135- element . current ,
136- childElementsDetached . current ,
137- restoreParentLink ,
138- ] ) ;
134+ } , [ ] ) ;
139135
140136 const updateCssClasses = useCallback ( ( prevProps : ( P & ComponentBaseProps ) | undefined , newProps : P & ComponentBaseProps ) => {
141137 const prevClassName = prevProps ? getClassName ( prevProps ) : undefined ;
@@ -156,7 +152,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
156152 element . current ?. classList . add ( ...classNames ) ;
157153 }
158154 }
159- } , [ element . current ] ) ;
155+ } , [ ] ) ;
160156
161157 const setInlineStyles = useCallback ( ( styles ) => {
162158 if ( element . current ) {
@@ -172,7 +168,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
172168 } ,
173169 ) ;
174170 }
175- } , [ element . current ] ) ;
171+ } , [ ] ) ;
176172
177173 const setTemplateManagerHooks = useCallback ( ( {
178174 createDXTemplates : createDXTemplatesFn ,
@@ -182,11 +178,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
182178 createDXTemplates . current = createDXTemplatesFn ;
183179 clearInstantiationModels . current = clearInstantiationModelsFn ;
184180 updateTemplates . current = updateTemplatesFn ;
185- } , [
186- createDXTemplates . current ,
187- clearInstantiationModels . current ,
188- updateTemplates . current ,
189- ] ) ;
181+ } , [ ] ) ;
190182
191183 const getElementProps = useCallback ( ( ) => {
192184 const elementProps : Record < string , any > = {
@@ -203,7 +195,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
203195 }
204196 } ) ;
205197 return elementProps ;
206- } , [ element . current , props ] ) ;
198+ } , [ props ] ) ;
207199
208200 const scheduleTemplatesUpdate = useCallback ( ( ) => {
209201 if ( guardsUpdateScheduled . current ) {
@@ -221,11 +213,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
221213 } ) ;
222214
223215 unscheduleGuards ( ) ;
224- } , [
225- guardsUpdateScheduled . current ,
226- useDeferUpdateForTemplates . current ,
227- updateTemplates . current ,
228- ] ) ;
216+ } , [ ] ) ;
229217
230218 const createWidget = useCallback ( ( el ?: Element ) => {
231219 beforeCreateWidget ( ) ;
@@ -266,14 +254,8 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
266254 } , [
267255 beforeCreateWidget ,
268256 afterCreateWidget ,
269- element . current ,
270- optionsManager . current ,
271- createDXTemplates . current ,
272- clearInstantiationModels . current ,
273257 WidgetClass ,
274258 useRequestAnimationFrameFlag ,
275- useDeferUpdateForTemplates . current ,
276- instance . current ,
277259 subscribableOptions ,
278260 independentEvents ,
279261 widgetConfig ,
@@ -284,7 +266,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
284266 instance . current . focus ( ) ;
285267 shouldRestoreFocus . current = false ;
286268 }
287- } , [ shouldRestoreFocus . current , instance . current ] ) ;
269+ } , [ ] ) ;
288270
289271 const onComponentUpdated = useCallback ( ( ) => {
290272 if ( ! optionsManager . current ?. isInstanceSet ) {
@@ -301,9 +283,6 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
301283
302284 prevPropsRef . current = props ;
303285 } , [
304- optionsManager . current ,
305- prevPropsRef . current ,
306- createDXTemplates . current ,
307286 scheduleTemplatesUpdate ,
308287 updateCssClasses ,
309288 props ,
@@ -326,9 +305,6 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
326305
327306 prevPropsRef . current = props ;
328307 } , [
329- childNodes . current ,
330- element . current ,
331- childElementsDetached . current ,
332308 updateCssClasses ,
333309 setInlineStyles ,
334310 props ,
@@ -358,15 +334,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
358334 optionsManager . current . dispose ( ) ;
359335
360336 removalLocker ?. unlock ( ) ;
361- } , [
362- removalLocker ,
363- instance . current ,
364- childNodes . current ,
365- element . current ,
366- optionsManager . current ,
367- childElementsDetached . current ,
368- shouldRestoreFocus . current ,
369- ] ) ;
337+ } , [ removalLocker ] ) ;
370338
371339 useLayoutEffect ( ( ) => {
372340 onComponentMounted ( ) ;
@@ -376,10 +344,20 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
376344 } ;
377345 } , [ ] ) ;
378346
347+ useLayoutEffect ( ( ) => {
348+ restoreParentLinkRef . current = restoreParentLink ;
349+ } , [ restoreParentLink ] ) ;
350+
379351 useLayoutEffect ( ( ) => {
380352 onComponentUpdated ( ) ;
381353 } ) ;
382354
355+ const createWidgetRef = useRef ( createWidget ) ;
356+
357+ useLayoutEffect ( ( ) => {
358+ createWidgetRef . current = createWidget ;
359+ } , [ createWidget ] ) ;
360+
383361 useImperativeHandle ( ref , ( ) => (
384362 {
385363 getInstance ( ) {
@@ -389,10 +367,10 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
389367 return element . current ;
390368 } ,
391369 createWidget ( el ) {
392- createWidget ( el ) ;
370+ createWidgetRef . current ?. ( el ) ;
393371 } ,
394372 }
395- ) , [ instance . current , element . current , createWidget ] ) ;
373+ ) , [ ] ) ;
396374
397375 const _renderChildren = useCallback ( ( ) => {
398376 if ( renderChildren ) {
@@ -406,7 +384,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
406384 const renderPortal = useCallback ( ( ) => portalContainer . current && createPortal (
407385 _renderChildren ( ) ,
408386 portalContainer . current ,
409- ) , [ portalContainer . current , _renderChildren ] ) ;
387+ ) , [ _renderChildren ] ) ;
410388
411389 const renderContent = useCallback ( ( ) => {
412390 const { children } = props ;
@@ -425,7 +403,6 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
425403 } , [
426404 props ,
427405 isPortalComponent ,
428- portalContainer . current ,
429406 _renderChildren ,
430407 ] ) ;
431408
0 commit comments