@@ -54,7 +54,11 @@ const ObjectInspector = React.createClass({
54
54
getObjectProperties : PropTypes . func . isRequired ,
55
55
loadObjectProperties : PropTypes . func . isRequired ,
56
56
onLabelClick : PropTypes . func ,
57
- onDoubleClick : PropTypes . func
57
+ onDoubleClick : PropTypes . func ,
58
+ getExpanded : PropTypes . func ,
59
+ setExpanded : PropTypes . func ,
60
+ getActors : PropTypes . func ,
61
+ setActors : PropTypes . func
58
62
} ,
59
63
60
64
displayName : "ObjectInspector" ,
@@ -63,7 +67,6 @@ const ObjectInspector = React.createClass({
63
67
// Cache of dynamically built nodes. We shouldn't need to clear
64
68
// this out ever, since we don't ever "switch out" the object
65
69
// being inspected.
66
- this . actorCache = { } ;
67
70
return { } ;
68
71
} ,
69
72
@@ -75,6 +78,18 @@ const ObjectInspector = React.createClass({
75
78
} ;
76
79
} ,
77
80
81
+ componentWillMount ( ) {
82
+ if ( this . props . getActors ) {
83
+ this . actors = this . props . getActors ( ) ;
84
+ }
85
+ } ,
86
+
87
+ componentWillUnmount ( ) {
88
+ if ( this . props . setActors ) {
89
+ this . props . setActors ( this . actors ) ;
90
+ }
91
+ } ,
92
+
78
93
getChildren ( item ) {
79
94
const { getObjectProperties } = this . props ;
80
95
const obj = item . contents ;
@@ -95,8 +110,8 @@ const ObjectInspector = React.createClass({
95
110
// being the same across renders. If we didn't do this, each
96
111
// node would be a new instance every render.
97
112
const key = item . path ;
98
- if ( this . actorCache [ key ] ) {
99
- return this . actorCache [ key ] ;
113
+ if ( this . actors [ key ] ) {
114
+ return this . actors [ key ] ;
100
115
}
101
116
102
117
const loadedProps = getObjectProperties ( actor ) ;
@@ -106,7 +121,7 @@ const ObjectInspector = React.createClass({
106
121
}
107
122
108
123
const children = makeNodesForProperties ( loadedProps , item . path ) ;
109
- this . actorCache [ actor ] = children ;
124
+ this . actors [ key ] = children ;
110
125
return children ;
111
126
}
112
127
@@ -167,8 +182,10 @@ const ObjectInspector = React.createClass({
167
182
} ,
168
183
169
184
render ( ) {
170
- const { name, desc, loadObjectProperties,
171
- autoExpandDepth } = this . props ;
185
+ const {
186
+ name, desc, loadObjectProperties,
187
+ autoExpandDepth, getExpanded, setExpanded
188
+ } = this . props ;
172
189
173
190
let roots = this . props . roots ;
174
191
if ( ! roots ) {
@@ -190,7 +207,8 @@ const ObjectInspector = React.createClass({
190
207
loadObjectProperties ( item . contents . value ) ;
191
208
}
192
209
} ,
193
-
210
+ getExpanded,
211
+ setExpanded,
194
212
renderItem : this . renderItem
195
213
} ) ;
196
214
}
0 commit comments