forked from Trihydro/react-native-device-log
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug-view.js
50 lines (44 loc) · 1.03 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
50
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(props) {
super(props);
this.state = {
rows: [],
};
this.unmounted = false;
this.updateDebounced = debounce(this.update.bind(this), 150);
this.DebugService = props.DebugService;
}
componentWillUnmount() {
this.unmounted = true;
if (this.listner) {
this.listner();
}
}
update(data) {
if (data) {
if (!this.unmounted) {
this.setState({ rows: data });
}
}
}
componentDidMount() {
this.listner = this.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,
},
});