diff --git a/packages/client/src/schema-component/components/SchemaComponent.tsx b/packages/client/src/schema-component/components/SchemaComponent.tsx index 98f19a4c3..8ab13b8c5 100644 --- a/packages/client/src/schema-component/components/SchemaComponent.tsx +++ b/packages/client/src/schema-component/components/SchemaComponent.tsx @@ -1,5 +1,5 @@ -import React, { useContext, useEffect, useMemo } from 'react'; -import { Schema, ISchemaFieldProps } from '@formily/react'; +import { ISchemaFieldProps, Schema } from '@formily/react'; +import React, { useContext, useEffect, useMemo, useRef } from 'react'; import { SchemaComponentContext } from '../context'; function toSchema(schema?: any) { @@ -21,11 +21,13 @@ export function SchemaComponent(props: ISchemaFieldProps) { const { schema: defaultSchema, ...others } = props; const { reset, SchemaField } = useContext(SchemaComponentContext); const schema = useMemo(() => toSchema(defaultSchema), []); - // @ts-ignore - // console.log('defaultSchema', JSON.stringify(schema.toJSON())); - // TODO + const isInitialMount = useRef(true); useEffect(() => { + if (isInitialMount.current) { + isInitialMount.current = false; + } else { reset(); + } }, [JSON.stringify(defaultSchema)]); return ; }