Skip to content

Commit 22b4cfa

Browse files
authored
Merge pull request #184 from open-source-labs/staging
Staging
2 parents 85c472e + 50fc9a6 commit 22b4cfa

File tree

6 files changed

+59
-8
lines changed

6 files changed

+59
-8
lines changed

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/reducers/mainReducer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ export default (state, action) => produce(state, draft => {
2525

2626
const objChildArray = [];
2727
// eslint-disable-next-line no-restricted-syntax
28-
for (const objChild of obj.children) {
29-
objChildArray.push(findName(index, objChild));
28+
if (obj) {
29+
for (const objChild of obj.children) {
30+
objChildArray.push(findName(index, objChild));
31+
}
3032
}
3133
// eslint-disable-next-line no-restricted-syntax
3234
for (const objChildName of objChildArray) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.json-tree {
22
margin: 10px;
33
padding: 0;
4+
width: 900px;
45
background-color: $brand-color;
56
list-style: none;
67
}

src/backend/helpers.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ export const throttle = (f, t) => {
5151
// Helper function to grab the getters/setters from `elementType`
5252
export const getHooksNames = elementType => {
5353
// Initialize empty object to store the setters and getter
54-
let ast = JSXParser.parse(elementType);
54+
let ast;
55+
try {
56+
ast = JSXParser.parse(elementType);
57+
} catch(e) {
58+
return ['unknown'];
59+
}
5560
const hookState = {};
5661
const hooksNames = {};
5762

src/backend/tree.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ function scrubUnserializableMembers(tree: Tree): Tree {
1818
return tree;
1919
}
2020

21+
function serializeState(state) {
22+
try {
23+
return JSON.parse(JSON.stringify(state));
24+
} catch (e) {
25+
return 'circularState';
26+
};
27+
}
28+
2129
/**
22-
*
30+
*
2331
* This is the current snapshot that is being sent to the snapshots array.
24-
*
32+
*
2533
*/
2634
class Tree {
2735
/**
@@ -42,7 +50,7 @@ class Tree {
4250
parent: Tree
4351

4452
constructor(state : string | {}, name = 'nameless', componentData: {} = {}) {
45-
this.state = state === 'root' ? 'root' : JSON.parse(JSON.stringify(state));
53+
this.state = state === 'root' ? 'root' : serializeState(state); // JSON.parse(JSON.stringify(state));
4654
this.name = name;
4755
this.componentData = componentData ? JSON.parse(JSON.stringify(componentData)) : {};
4856
this.children = [];
@@ -62,15 +70,16 @@ class Tree {
6270
this.parent.children.push(newSibling);
6371
return newSibling;
6472
}
73+
6574
/**
6675
* @function cleanTreeCopy : Adds a sibing to the current tree
6776
*/
6877
cleanTreeCopy(): Tree {
6978
/**
7079
* @object circularComponentTable : Clears circular component table only on first call, not recursive ones
71-
*
80+
*
7281
*/
73-
//
82+
//
7483
if (copyInstances === 0) {
7584
copyInstances++;
7685
circularComponentTable.clear();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules/*
2+
!/node_modules/reactime
3+
.DS_Store

0 commit comments

Comments
 (0)