UNPKG

devextreme-react

Version:

DevExtreme React UI and Visualization Components

40 lines (38 loc) 1.29 kB
/*! * devextreme-react * Version: 24.2.6 * Build date: Mon Mar 17 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file in the root of the project for details. * * https://github.com/DevExpress/devextreme-react */ import { memo, useContext, useLayoutEffect } from 'react'; import { NestedOptionContext, TemplateRenderingContext } from './contexts'; import { getNamedTemplate } from './configuration/react/templates'; const Template = memo((props) => { const { onNamedTemplateReady, treeUpdateToken, } = useContext(NestedOptionContext); const { isTemplateRendering } = useContext(TemplateRenderingContext); const template = getNamedTemplate(props); useLayoutEffect(() => { if (!isTemplateRendering) { onNamedTemplateReady(template, treeUpdateToken); } }, [treeUpdateToken]); return null; }); function findProps(child) { if (child.type !== Template) { return undefined; } return { name: child.props.name, render: child.props.render, component: child.props.component, children: child.props.children, }; } export { Template, findProps, };