Skip to content

Commit 1ceff00

Browse files
fix: recover after react 19 compatibility fix (#28661)
1 parent 0df916e commit 1ceff00

File tree

2 files changed

+23
-39
lines changed

2 files changed

+23
-39
lines changed

packages/devextreme-react/src/core/component-base.tsx

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ import { DXRemoveCustomArgs, DXTemplateCreator, InitArgument } from './types';
2525
import { elementPropNames, getClassName } from './widget-config';
2626
import { TemplateManager } from './template-manager';
2727
import { 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

3130
import {
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

packages/devextreme-react/src/core/use-option-scanning.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
useContext,
66
useRef,
77
useLayoutEffect,
8-
useMemo,
98
} from 'react';
109

1110
import { ElementType, getElementType, IOptionElement } from './configuration/react/element';
@@ -32,13 +31,7 @@ export function useOptionScanning(
3231

3332
const updateToken = Symbol('update token');
3433

35-
const configBuilder = useMemo(
36-
() => createConfigBuilder(optionElement, parentFullName),
37-
[
38-
optionElement,
39-
parentFullName,
40-
],
41-
);
34+
const configBuilder = createConfigBuilder(optionElement, parentFullName);
4235

4336
Children.forEach(
4437
children,

0 commit comments

Comments
 (0)