forked from bright-systems/react-native-device-log
-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug-view.js
49 lines (43 loc) · 1.11 KB
/
debug-view.js
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
47
48
49
import React from "react";
import { View, StyleSheet } from "react-native";
import DebugListView from "./debug-list-view.js";
import debugService from "./debug-service";
import debounce from "debounce";
export default class DebugView extends React.Component {
constructor() {
super();
this.state = {
rows: [],
};
this.unmounted = false;
this.updateDebounced = debounce(this.update.bind(this), 150);
}
componentWillUnmount() {
this.unmounted = true;
if (this.listner) {
this.listner();
}
}
update(data) {
if (data) {
if (!this.unmounted) {
this.setState({ rows: data });
}
}
}
UNSAFE_componentWillMount() {
this.listner = debugService.onDebugRowsChanged(this.updateDebounced);
}
render() {
return (
<View style={styles.container}>
<DebugListView rows={this.state.rows} {...this.props} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});