This commit is contained in:
Morten
2018-08-14 10:24:19 +02:00
commit 38b440e2f6
33 changed files with 12188 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
import { Component } from 'react';
import log from '../../log';
class Log extends Component {
constructor() {
super();
this.state = {
logs: [],
};
this.addLog = this.addLog.bind(this);
}
componentDidMount() {
log.listen(this.addLog);
}
componentWillUnmount() {
log.unlisten(this.addLog);
}
addLog(entry) {
entry = Array.isArray(entry) ? entry : [entry];
const logs = [
...this.state.logs,
...entry,
];
this.setState({
logs,
});
}
render() {
const {
children,
} = this.props;
const component = children(
this.state,
);
return component;
}
}
export default Log;