fix: useExpressionScope (#3805)

This commit is contained in:
chenos 2024-03-24 12:51:41 +08:00 committed by GitHub
parent 5ee278557d
commit 921696f40b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,7 @@
import { useExpressionScope } from '@formily/react';
import { merge, omit } from 'lodash'; import { merge, omit } from 'lodash';
import React, { ComponentType, useMemo } from 'react'; import React, { ComponentType, useMemo } from 'react';
import { useDesignable, useSchemaComponentContext } from '../../schema-component'; import { useDesignable } from '../../schema-component';
const useDefaultSchemaProps = () => undefined; const useDefaultSchemaProps = () => undefined;
@ -12,7 +13,7 @@ export function withDynamicSchemaProps<T = any>(Component: ComponentType<T>, opt
const displayName = options.displayName || Component.displayName || Component.name; const displayName = options.displayName || Component.displayName || Component.name;
const ComponentWithProps: ComponentType<T> = (props) => { const ComponentWithProps: ComponentType<T> = (props) => {
const { dn, findComponent } = useDesignable(); const { dn, findComponent } = useDesignable();
const { scope } = useSchemaComponentContext(); const scope = useExpressionScope();
const useComponentPropsStr = useMemo(() => { const useComponentPropsStr = useMemo(() => {
const xComponent = dn.getSchemaAttribute('x-component'); const xComponent = dn.getSchemaAttribute('x-component');
const xDecorator = dn.getSchemaAttribute('x-decorator'); const xDecorator = dn.getSchemaAttribute('x-decorator');