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
41 lines (33 loc) · 1.01 KB
/
index.tsx
File metadata and controls
41 lines (33 loc) · 1.01 KB
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
import * as React from 'react'
import { AppMessage } from '../../overmind/types'
import Inspector from '../Inspector'
import * as styles from './styles'
type Props = {
message: AppMessage<any>
delimiter: string
}
const ConsoleRow: React.FunctionComponent<Props> = ({ message, delimiter }) => {
const [expandedPaths, setExpandedPaths] = React.useState<string[]>([])
function onToggleExpand(pathArray: string[]) {
const expandedPathsCopy = expandedPaths.slice()
const path = pathArray.join('.')
if (expandedPathsCopy.includes(path)) {
expandedPathsCopy.splice(expandedPathsCopy.indexOf(path), 1)
} else {
expandedPathsCopy.push(path)
}
setExpandedPaths(expandedPathsCopy)
}
return (
<div className={styles.wrapper}>
<div className={styles.type}>{message.type}</div>
<Inspector
delimiter={delimiter}
value={message.data}
expandedPaths={expandedPaths}
onToggleExpand={onToggleExpand}
/>
</div>
)
}
export default ConsoleRow