Skip to content

Commit

Permalink
fix: address React 19 BC due to which configuration components do not…
Browse files Browse the repository at this point in the history
… apply their options (T1269933) (#28654)
  • Loading branch information
VasilyStrelyaev authored Dec 30, 2024
1 parent e32f56f commit 67546f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
31 changes: 18 additions & 13 deletions packages/devextreme-react/src/core/component-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { DXRemoveCustomArgs, DXTemplateCreator, InitArgument } from './types';
import { elementPropNames, getClassName } from './widget-config';
import { TemplateManager } from './template-manager';
import { ComponentProps } from './component';
import { ElementType } from './configuration/react/element';
import { ElementType, IOptionElement } from './configuration/react/element';
import { IConfigNode } from './configuration/config-node';

import {
Expand Down Expand Up @@ -341,19 +341,24 @@ const ComponentBase = forwardRef<ComponentBaseRef, any>(

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

const options = useOptionScanning(
{
type: ElementType.Option,
descriptor: {
name: '',
isCollection: false,
templates: templateProps,
initialValuesProps: defaults,
predefinedValuesProps: {},
expectedChildren,
},
props,
const elementDescriptor: IOptionElement = useMemo(() => ({
type: ElementType.Option,
descriptor: {
name: '',
isCollection: false,
templates: templateProps,
initialValuesProps: defaults,
predefinedValuesProps: {},
expectedChildren,
},
props,
}), [
templateProps,
defaults,
]);

const options = useOptionScanning(
elementDescriptor,
props.children,
templateContainer,
Symbol('initial update token'),
Expand Down
9 changes: 8 additions & 1 deletion packages/devextreme-react/src/core/use-option-scanning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useContext,
useRef,
useLayoutEffect,
useMemo,
} from 'react';

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

const updateToken = Symbol('update token');

const configBuilder = createConfigBuilder(optionElement, parentFullName);
const configBuilder = useMemo(
() => createConfigBuilder(optionElement, parentFullName),
[
optionElement,
parentFullName,
],
);

Children.forEach(
children,
Expand Down

0 comments on commit 67546f4

Please sign in to comment.