call getProcesses in componentDidMount

This commit is contained in:
Jonathan Rainville 2018-09-13 15:11:51 -04:00
parent 59757c08e2
commit d9b8b5ff68
1 changed files with 14 additions and 6 deletions

View File

@ -12,17 +12,25 @@ import {getProcesses, getCommands, getVersions, getProcessLogs} from "../reducer
import deepEqual from 'deep-equal';
class HomeContainer extends Component {
componentDidMount() {
this.getProcesses();
}
componentDidUpdate(prevProps) {
if (!deepEqual(this.props.processes, prevProps.processes)) {
this.props.processes.forEach(process => {
this.props.fetchProcessLogs(process.name);
if (!prevProps.processes.length) {
this.props.listenToProcessLogs(process.name);
}
});
this.getProcesses(prevProps);
}
}
getProcesses(prevProps) {
this.props.processes.forEach(process => {
this.props.fetchProcessLogs(process.name);
if (!prevProps || !prevProps.processes.length) {
this.props.listenToProcessLogs(process.name);
}
});
}
render() {
return (
<React.Fragment>