Skip to content

Commit

Permalink
fix(schema-renderer): fix schema field lazy state (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang authored Aug 16, 2020
1 parent 700be1d commit 8faab44
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions packages/react-schema-renderer/src/components/SchemaField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,22 @@ export const SchemaField: React.FunctionComponent<ISchemaFieldProps> = (
)
}

const renderProperties = () => {
return fieldSchema.mapProperties((schema: Schema, key: string) => {
const childPath = path.concat(key)
return (
<SchemaField
schema={schema}
key={childPath.toString()}
path={childPath}
/>
)
})
}

if (fieldSchema.isObject() && !schemaComponent) {
const properties = fieldSchema.mapProperties(
(schema: Schema, key: string) => {
const childPath = path.concat(key)
return (
<SchemaField
schema={schema}
key={childPath.toString()}
path={childPath}
/>
)
}
)
if (path.length == 0 || props.onlyRenderProperties) {
return <Fragment>{properties}</Fragment>
return <Fragment>{renderProperties()}</Fragment>
}
return renderFieldDelegate(props => {
const renderComponent = () => {
Expand All @@ -186,7 +187,7 @@ export const SchemaField: React.FunctionComponent<ISchemaFieldProps> = (
return React.createElement(
formRegistry.formItemComponent,
props,
properties
renderProperties()
)
}
if (isFn(schemaRenderer)) {
Expand Down

0 comments on commit 8faab44

Please sign in to comment.