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
46 lines (40 loc) · 987 Bytes
/
index.tsx
File metadata and controls
46 lines (40 loc) · 987 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
46
import * as React from 'react'
import Inspector from '../Inspector'
import { Wrapper, Type } from './elements'
import { AppMessage } from '../../app/state'
type Props = {
message: AppMessage
}
type State = {
expandedPaths: string[]
}
class ConsoleRow extends React.Component<Props, State> {
state = {
expandedPaths: [],
}
onToggleExpand = (pathArray) => {
const expandedPaths = this.state.expandedPaths.slice()
const path = pathArray.join('.')
if (expandedPaths.includes(path)) {
expandedPaths.splice(expandedPaths.indexOf(path), 1)
} else {
expandedPaths.push(path)
}
this.setState({
expandedPaths,
})
}
render() {
return (
<Wrapper>
<Type>{this.props.message.type}</Type>
<Inspector
value={this.props.message.data}
expandedPaths={this.state.expandedPaths}
onToggleExpand={this.onToggleExpand}
/>
</Wrapper>
)
}
}
export default ConsoleRow