fix(client): schema render
This commit is contained in:
parent
28a7cdbefb
commit
4422324980
@ -1,8 +1,10 @@
|
||||
import { createForm } from '@formily/core';
|
||||
import { Schema } from '@formily/react';
|
||||
import { Spin } from 'antd';
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { useRequest } from '../../api-client';
|
||||
import { useSchemaComponentContext } from '../hooks';
|
||||
import { FormProvider } from './FormProvider';
|
||||
import { SchemaComponent } from './SchemaComponent';
|
||||
|
||||
export interface RemoteSchemaComponentProps {
|
||||
@ -23,6 +25,7 @@ const RequestSchemaComponent: React.FC<RemoteSchemaComponentProps> = (props) =>
|
||||
const conf = {
|
||||
url: `/uiSchemas:${onlyRenderProperties ? 'getProperties' : 'getJsonSchema'}/${uid}`,
|
||||
};
|
||||
const form = useMemo(() => createForm(), [uid]);
|
||||
const { data, loading } = useRequest(conf, {
|
||||
refreshDeps: [uid],
|
||||
onSuccess(data) {
|
||||
@ -30,14 +33,17 @@ const RequestSchemaComponent: React.FC<RemoteSchemaComponentProps> = (props) =>
|
||||
reset && reset();
|
||||
},
|
||||
});
|
||||
|
||||
if (loading) {
|
||||
return <Spin />;
|
||||
}
|
||||
if (hidden) {
|
||||
return <Spin />;
|
||||
}
|
||||
return <SchemaComponent memoized scope={scope} schema={schemaTransform(data?.data || {})} />;
|
||||
return (
|
||||
<FormProvider form={form}>
|
||||
<SchemaComponent memoized scope={scope} schema={schemaTransform(data?.data || {})} />;
|
||||
</FormProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export const RemoteSchemaComponent: React.FC<RemoteSchemaComponentProps> = (props) => {
|
||||
|
Loading…
Reference in New Issue
Block a user