Skip to content

Commit b7c4881

Browse files
committed
fix: re-render tree correctly
1 parent f6892e2 commit b7c4881

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"dependencies": {
4646
"@stoplight/json": "^3.5.1",
4747
"@stoplight/react-error-boundary": "^1.0.0",
48-
"@stoplight/tree-list": "5.0.0-beta.1",
48+
"@stoplight/tree-list": "5.0.0-beta.2",
4949
"classnames": "^2.2.6",
5050
"json-schema-merge-allof": "https://github.com/stoplightio/json-schema-merge-allof",
5151
"lodash": "^4.17.15",

src/components/JsonSchemaViewer.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ErrorBoundaryForwardedProps, FallbackComponent, withErrorBoundary } from '@stoplight/react-error-boundary';
2-
import { TreeState, TreeStore } from '@stoplight/tree-list';
2+
import { Tree, TreeState, TreeStore } from '@stoplight/tree-list';
33
import cn from 'classnames';
44
import { action } from 'mobx';
55
import * as React from 'react';
@@ -61,10 +61,8 @@ export class JsonSchemaViewerComponent extends React.PureComponent<IJsonSchemaVi
6161
}
6262

6363
protected renderSchema() {
64-
if (this.tree.count > 1) {
65-
for (const child of this.tree) {
66-
this.tree.removeNode(child);
67-
}
64+
if (this.tree.count > 0) {
65+
this.tree.setRoot(Tree.createArtificialRoot());
6866
}
6967

7068
this.tree.populate();

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,10 +1671,10 @@
16711671
ts-loader "^6.2.1"
16721672
webpack "^4.41.5"
16731673

1674-
"@stoplight/tree-list@5.0.0-beta.1":
1675-
version "5.0.0-beta.1"
1676-
resolved "https://registry.yarnpkg.com/@stoplight/tree-list/-/tree-list-5.0.0-beta.1.tgz#5ec0b96365af3684d118403ef6fe1f6cc0c754b9"
1677-
integrity sha512-X2ShK7uugu+Aiunx45txafPUTV+0qxjDX5n9r1y5WcwK8Ds6XMgaM0/FgzTw4I9XWQ310WK77ndsEVNn9axrhQ==
1674+
"@stoplight/tree-list@5.0.0-beta.2":
1675+
version "5.0.0-beta.2"
1676+
resolved "https://registry.yarnpkg.com/@stoplight/tree-list/-/tree-list-5.0.0-beta.2.tgz#b60dbea9df1d3c7e01bdfd8dc05388978128df83"
1677+
integrity sha512-yZLakRr55gf8Z2ZYuJzh9v7NJGZ8MlsKncAMa8md5HqWKucHhZXJhvlJSHLz9cwnk5dfNXSDUf+Pgv2zBe4YJA==
16781678
dependencies:
16791679
"@stoplight/lifecycle" "^2.2.1"
16801680
"@stoplight/react-error-boundary" "^1.0.0"

0 commit comments

Comments
 (0)