mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
chore: 调整右侧面板构建优化对象属性下发减少re-render (#9961)
This commit is contained in:
parent
e64b239dd3
commit
671cfcc06d
@ -20,6 +20,7 @@ import type {DataScope} from 'amis-core';
|
|||||||
import type {RendererConfig} from 'amis-core';
|
import type {RendererConfig} from 'amis-core';
|
||||||
import type {SchemaCollection} from 'amis';
|
import type {SchemaCollection} from 'amis';
|
||||||
import {SchemaFrom} from './base/SchemaForm';
|
import {SchemaFrom} from './base/SchemaForm';
|
||||||
|
import memoize from 'lodash/memoize';
|
||||||
|
|
||||||
// 创建 Node Store 并构建成树
|
// 创建 Node Store 并构建成树
|
||||||
export function makeWrapper(
|
export function makeWrapper(
|
||||||
@ -237,6 +238,9 @@ export function makeSchemaFormRender(
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const env = {...manager.env, session: 'schema-form'};
|
const env = {...manager.env, session: 'schema-form'};
|
||||||
|
const filterBody = memoize(body =>
|
||||||
|
body ? flatten(Array.isArray(body) ? body : [body]) : undefined
|
||||||
|
);
|
||||||
|
|
||||||
return ({value, onChange, popOverContainer, id, store, node}: PanelProps) => {
|
return ({value, onChange, popOverContainer, id, store, node}: PanelProps) => {
|
||||||
const ctx = {...manager.store.ctx};
|
const ctx = {...manager.store.ctx};
|
||||||
@ -260,26 +264,17 @@ export function makeSchemaFormRender(
|
|||||||
schema.formKey ? schema.formKey : ''
|
schema.formKey ? schema.formKey : ''
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
|
const body = filterBody(schema.body);
|
||||||
|
const controls = filterBody(schema.controls);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaFrom
|
<SchemaFrom
|
||||||
key={curFormKey}
|
key={curFormKey}
|
||||||
propKey={curFormKey}
|
propKey={curFormKey}
|
||||||
api={schema.api}
|
api={schema.api}
|
||||||
definitions={schema.definitions}
|
definitions={schema.definitions}
|
||||||
body={
|
body={body}
|
||||||
schema.body
|
controls={controls}
|
||||||
? flatten(Array.isArray(schema.body) ? schema.body : [schema.body])
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
controls={
|
|
||||||
schema.controls
|
|
||||||
? flatten(
|
|
||||||
Array.isArray(schema.controls)
|
|
||||||
? schema.controls
|
|
||||||
: [schema.controls]
|
|
||||||
)
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
value={value}
|
value={value}
|
||||||
ctx={ctx}
|
ctx={ctx}
|
||||||
pipeIn={schema.pipeIn}
|
pipeIn={schema.pipeIn}
|
||||||
|
Loading…
Reference in New Issue
Block a user