Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: address React 19 BC due to which configuration components do not apply their options (T1269933) #28658

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions packages/devextreme-react/src/core/component-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { elementPropNames, getClassName } from './widget-config';
import { TemplateManager } from './template-manager';
import { ComponentProps } from './component';
import { ElementType } from './configuration/react/element';
import { IConfigNode } from './configuration/config-node';

import {
NestedOptionContext,
Expand Down Expand Up @@ -96,7 +95,25 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(

const prevPropsRef = useRef<P & ComponentBaseProps>();

let widgetConfig: IConfigNode;
const templateContainer = useMemo(() => document.createElement('div'), []);

const [widgetConfig, context] = useOptionScanning(
{
type: ElementType.Option,
descriptor: {
name: '',
isCollection: false,
templates: templateProps,
initialValuesProps: defaults,
predefinedValuesProps: {},
expectedChildren,
},
props,
},
props.children,
templateContainer,
Symbol('initial update token'),
);

const restoreTree = useCallback(() => {
if (childElementsDetached.current && childNodes.current?.length && element.current) {
Expand Down Expand Up @@ -249,6 +266,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
instance.current,
subscribableOptions,
independentEvents,
widgetConfig,
]);

const onTemplatesRendered = useCallback(() => {
Expand Down Expand Up @@ -279,6 +297,7 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
scheduleTemplatesUpdate,
updateCssClasses,
props,
widgetConfig,
]);

const onComponentMounted = useCallback(() => {
Expand Down Expand Up @@ -339,29 +358,6 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(
shouldRestoreFocus.current,
]);

const templateContainer = useMemo(() => document.createElement('div'), []);

const options = useOptionScanning(
{
type: ElementType.Option,
descriptor: {
name: '',
isCollection: false,
templates: templateProps,
initialValuesProps: defaults,
predefinedValuesProps: {},
expectedChildren,
},
props,
},
props.children,
templateContainer,
Symbol('initial update token'),
);

[widgetConfig] = options;
const [, context] = options;

useLayoutEffect(() => {
onComponentMounted();

Expand Down
Loading