remove state mutations from render

This commit is contained in:
2019-02-11 14:55:58 +03:00
parent 37824ad373
commit adde6566db
2 changed files with 16 additions and 4 deletions

View File

@@ -107,7 +107,6 @@ export class DocumentEditComponent extends React.PureComponent<
</div>
);
} else {
this.tryLoad();
return this.props.spinner && <LoadingStub />;
}
}
@@ -138,6 +137,10 @@ export class DocumentEditComponent extends React.PureComponent<
this.tryLoad();
}
public componentDidMount() {
this.tryLoad();
}
private tryLoad() {
if (!this.props.allDocs && !this.props.fetching) {
this.props.fetchDocs();

View File

@@ -47,12 +47,21 @@ export class OverviewComponent extends React.PureComponent<
</div>
);
} else {
if (!this.props.fetching) {
this.props.fetchDocs();
}
return this.props.spinner && <LoadingStub />;
}
}
public componentDidUpdate() {
if (!this.props.allDocs && !this.props.fetching) {
this.props.fetchDocs();
}
}
public componentDidMount() {
if (!this.props.allDocs && !this.props.fetching) {
this.props.fetchDocs();
}
}
}
function mapStateToProps(state: IAppState) {