@@ -26,7 +26,7 @@ type ShowMenu = boolean | (e: DOMEvent, val: any, path: Array<string>, name: str
2626type DataViewProps = {
2727 data : ?any ,
2828 path : Array < string > ,
29- inspect : Inspect ,
29+ inspect : Inspect | null ,
3030 showMenu : ShowMenu ,
3131 startOpen ?: boolean ,
3232 noSort ?: boolean ,
@@ -155,7 +155,7 @@ DataView.contextTypes = {
155155
156156type Props = {
157157 path : Array < string > ,
158- inspect : Inspect ,
158+ inspect : Inspect | null ,
159159 showMenu : ShowMenu ,
160160 startOpen ?: boolean ,
161161 noSort ?: boolean ,
@@ -195,25 +195,34 @@ class DataItem extends React.Component<Props, State> {
195195 }
196196
197197 inspect ( ) {
198+ const inspect = this . props . inspect ;
199+ if ( inspect === null ) {
200+ // The Profiler displays props/state for oudated Fibers.
201+ // These Fibers have already been mutated so they can't be inspected.
202+ return ;
203+ }
204+
198205 this . setState ( { loading : true , open : true } ) ;
199- this . props . inspect ( this . props . path , ( ) => {
206+ inspect ( this . props . path , ( ) => {
200207 this . setState ( { loading : false } ) ;
201208 } ) ;
202209 }
203210
204- toggleOpen ( ) {
211+ toggleOpen = ( ) => {
205212 if ( this . state . loading ) {
206213 return ;
207214 }
208- if ( this . props . value && this . props . value [ consts . inspected ] === false ) {
215+
216+ const { value } = this . props ;
217+ if ( value && value [ consts . inspected ] === false ) {
209218 this . inspect ( ) ;
210219 return ;
211220 }
212221
213222 this . setState ( {
214223 open : ! this . state . open ,
215224 } ) ;
216- }
225+ } ;
217226
218227 toggleBooleanValue ( e ) {
219228 this . context . onChange ( this . props . path , e . target . checked ) ;
@@ -238,14 +247,14 @@ class DataItem extends React.Component<Props, State> {
238247 preview = previewComplex ( data , theme ) ;
239248 }
240249
241- var inspectable = ! data || ! data [ consts . meta ] || ! data [ consts . meta ] . uninspectable ;
242- var open = inspectable && this . state . open && ( ! data || data [ consts . inspected ] !== false ) ;
250+ var inspectable = typeof this . props . inspect === 'function' && ( ! data || ! data [ consts . meta ] || ! data [ consts . meta ] . uninspectable ) ;
251+ var open = this . state . open && ( ! data || data [ consts . inspected ] !== false ) ;
243252 var opener = null ;
244253
245254 if ( complex && inspectable ) {
246255 opener = (
247256 < div
248- onClick = { this . toggleOpen . bind ( this ) }
257+ onClick = { this . toggleOpen }
249258 style = { styles . opener } >
250259 { open ?
251260 < span style = { expandedArrowStyle ( theme ) } /> :
@@ -292,8 +301,8 @@ class DataItem extends React.Component<Props, State> {
292301 {
293302 ! this . props . hideName &&
294303 < div
295- style = { nameStyle ( complex , theme ) }
296- onClick = { inspectable && this . toggleOpen . bind ( this ) }
304+ style = { nameStyle ( complex , inspectable , theme ) }
305+ onClick = { inspectable ? this . toggleOpen : undefined }
297306 >
298307 { name } :
299308 </ div >
@@ -330,8 +339,8 @@ function alphanumericSort(a: string, b: string): number {
330339 return ( a < b ) ? - 1 : 1 ;
331340}
332341
333- const nameStyle = ( isComplex : boolean , theme : Theme ) => ( {
334- cursor : isComplex ? 'pointer' : 'default' ,
342+ const nameStyle = ( isComplex : boolean , isInspectable : boolean , theme : Theme ) => ( {
343+ cursor : isComplex && isInspectable ? 'pointer' : 'default' ,
335344 color : theme . special03 ,
336345 margin : '0 0.25rem' ,
337346} ) ;
0 commit comments