forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
45 lines (41 loc) · 909 Bytes
/
index.tsx
File metadata and controls
45 lines (41 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import * as React from 'react'
import Inspector from '../Inspector'
type State = {
expandedPaths: string[]
}
class ValueInspector extends React.Component<
{
value: any
small?: boolean
},
State
> {
state = {
expandedPaths: [],
}
onToggleExpand = (path) => {
const pathString = path.join('')
if (this.state.expandedPaths.includes(pathString)) {
this.setState({
expandedPaths: this.state.expandedPaths.filter(
(currentPath) => currentPath !== pathString
),
})
} else {
this.setState({
expandedPaths: this.state.expandedPaths.concat(pathString),
})
}
}
render() {
return (
<Inspector
value={this.props.value}
expandedPaths={this.state.expandedPaths}
onToggleExpand={this.onToggleExpand}
small={this.props.small}
/>
)
}
}
export default ValueInspector