Skip to content

Commit

Permalink
[react] Only set resolving flag if new schemas has refs in JsonFors c…
Browse files Browse the repository at this point in the history
…omponent
  • Loading branch information
edgarmueller committed Mar 22, 2019
1 parent eaef688 commit f2409dc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/react/src/JsonForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ interface JsonFormsRendererState {
resolvedSchema: JsonSchema;
}

const hasRefs = (schema: JsonSchema) => {
const hasRefs = (schema: JsonSchema): boolean => {
if (schema !== undefined) {
return Object.keys(findRefs(schema)).length > 0;
}
Expand All @@ -62,11 +62,12 @@ export class ResolvedJsonFormsDispatchRenderer
) {

if (!isEqual(prevState.schema, nextProps.schema)) {
const schemaHasRefs: boolean = hasRefs(nextProps.schema);
const newState: JsonFormsRendererState = {
id: prevState.id,
resolvedSchema: undefined,
resolvedSchema: schemaHasRefs ? undefined : nextProps.schema,
schema: nextProps.schema,
resolving: true,
resolving: schemaHasRefs,
};
return newState;
}
Expand Down

0 comments on commit f2409dc

Please sign in to comment.