mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Added simple hooks support (same as in legacy DevTools for now)
I had to add a couple of comments because Flow was being a mysterious little shit and I got tired of trying to work around it.
This commit is contained in:
1 parent
d0d5b677de
commit
33deb79ce4
12 files changed
+187
-63
No files matched your search
@@ -1,6 +1,7 @@
|
||||
// @flow
|
||||
|
||||
import React from 'react';
|
||||
import { getMetaValueLabel } from './utils';
|
||||
import { meta } from '../../hydration';
|
||||
import styles from './InspectedElementTree.css';
|
||||
|
||||
@@ -15,7 +16,6 @@ export default function InspectedElementTree({ data, label }: Props) {
|
||||
} else {
|
||||
// TODO Add click and key handlers for toggling element open/close state.
|
||||
// TODO Support editable props
|
||||
|
||||
return (
|
||||
<div className={styles.InspectedElementTree}>
|
||||
<div className={styles.Item}>{label}</div>
|
||||
@@ -108,24 +108,3 @@ function KeyValue({ depth, name, value }: KeyValueProps) {
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
function getMetaValueLabel(data: Object): string | null {
|
||||
switch (data[meta.type]) {
|
||||
case 'function':
|
||||
return `${data[meta.name] || 'fn'}()`;
|
||||
case 'object':
|
||||
return 'Object';
|
||||
case 'date':
|
||||
case 'symbol':
|
||||
return data[meta.name];
|
||||
case 'iterator':
|
||||
return `${data[meta.name]}(…)`;
|
||||
case 'array_buffer':
|
||||
case 'data_view':
|
||||
case 'array':
|
||||
case 'typed_array':
|
||||
return `${data[meta.name]}[${data[meta.meta].length}]`;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user