Skip to content

Commit

Permalink
fix: resolveRef
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed Feb 27, 2020
1 parent e59a5f2 commit 13ffc48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/components/JsonSchemaViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ export class JsonSchemaViewerComponent extends React.PureComponent<IJsonSchemaVi

@action
public componentDidUpdate(prevProps: Readonly<IJsonSchemaViewer>) {
if (this.treeStore.defaultExpandedDepth !== this.expandedDepth) {
if (prevProps.resolveRef !== this.props.resolveRef) {
this.tree.resolveRef = this.props.resolveRef;
}

if (
this.treeStore.defaultExpandedDepth !== this.expandedDepth ||
prevProps.schema !== this.props.schema ||
prevProps.mergeAllOf !== this.props.mergeAllOf
) {
this.treeStore.defaultExpandedDepth = this.expandedDepth;
this.tree.expandedDepth = this.expandedDepth;
this.renderSchema();
} else if (prevProps.schema !== this.props.schema || prevProps.mergeAllOf !== this.props.mergeAllOf) {
this.tree.mergeAllOf = this.mergeAllOf;
this.tree.schema = this.props.schema;
this.renderSchema();
Expand Down
2 changes: 1 addition & 1 deletion src/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export { TreeState as SchemaTreeState };
export class SchemaTree extends Tree {
public expandedDepth: number;
public mergeAllOf: boolean;
protected resolveRef: Optional<SchemaTreeRefDereferenceFn>;
public resolveRef: Optional<SchemaTreeRefDereferenceFn>;

constructor(public schema: JSONSchema4, public state: TreeState, opts: SchemaTreeOptions) {
super();
Expand Down

0 comments on commit 13ffc48

Please sign in to comment.