@@ -25,8 +25,7 @@ import { DXRemoveCustomArgs, DXTemplateCreator, InitArgument } from './types';
2525import { elementPropNames , getClassName } from './widget-config' ;
2626import { TemplateManager } from './template-manager' ;
2727import { ComponentProps } from './component' ;
28- import { ElementType , IOptionElement } from './configuration/react/element' ;
29- import { IConfigNode } from './configuration/config-node' ;
28+ import { ElementType } from './configuration/react/element' ;
3029
3130import {
3231 NestedOptionContext ,
@@ -96,7 +95,25 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
9695
9796 const prevPropsRef = useRef < P & ComponentBaseProps > ( ) ;
9897
99- let widgetConfig : IConfigNode ;
98+ const templateContainer = useMemo ( ( ) => document . createElement ( 'div' ) , [ ] ) ;
99+
100+ const [ widgetConfig , context ] = useOptionScanning (
101+ {
102+ type : ElementType . Option ,
103+ descriptor : {
104+ name : '' ,
105+ isCollection : false ,
106+ templates : templateProps ,
107+ initialValuesProps : defaults ,
108+ predefinedValuesProps : { } ,
109+ expectedChildren,
110+ } ,
111+ props,
112+ } ,
113+ props . children ,
114+ templateContainer ,
115+ Symbol ( 'initial update token' ) ,
116+ ) ;
100117
101118 const restoreTree = useCallback ( ( ) => {
102119 if ( childElementsDetached . current && childNodes . current ?. length && element . current ) {
@@ -249,6 +266,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
249266 instance . current ,
250267 subscribableOptions ,
251268 independentEvents ,
269+ widgetConfig ,
252270 ] ) ;
253271
254272 const onTemplatesRendered = useCallback ( ( ) => {
@@ -279,6 +297,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
279297 scheduleTemplatesUpdate ,
280298 updateCssClasses ,
281299 props ,
300+ widgetConfig ,
282301 ] ) ;
283302
284303 const onComponentMounted = useCallback ( ( ) => {
@@ -339,34 +358,6 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
339358 shouldRestoreFocus . current ,
340359 ] ) ;
341360
342- const templateContainer = useMemo ( ( ) => document . createElement ( 'div' ) , [ ] ) ;
343-
344- const elementDescriptor : IOptionElement = useMemo ( ( ) => ( {
345- type : ElementType . Option ,
346- descriptor : {
347- name : '' ,
348- isCollection : false ,
349- templates : templateProps ,
350- initialValuesProps : defaults ,
351- predefinedValuesProps : { } ,
352- expectedChildren,
353- } ,
354- props,
355- } ) , [
356- templateProps ,
357- defaults ,
358- ] ) ;
359-
360- const options = useOptionScanning (
361- elementDescriptor ,
362- props . children ,
363- templateContainer ,
364- Symbol ( 'initial update token' ) ,
365- ) ;
366-
367- [ widgetConfig ] = options ;
368- const [ , context ] = options ;
369-
370361 useLayoutEffect ( ( ) => {
371362 onComponentMounted ( ) ;
372363
0 commit comments