Answer the question
In order to leave comments, you need to log in
How to stop persistent api request?
Good afternoon!
Tell me please.
How to stop persistent api request??
Here is the code.
As I understand it, in "public update ()", you need to write some kind of condition.
class VdcDetailsPage extends React.Component {
public update(): void {
this.props.actions.getVdcs();
this.props.actions.vdcDetailsLoad(this.props.match.params.vdcid);
}
public componentDidUpdate(prevProps): void {
this.update();
}
public componentDidMount(): void {
this.update();
}
public render(): React.ReactNode {
if (this.props.vdcs.loading || !("LIMIT_CPU_COUNT" in this.props.VDC) ) {
return <div />
}
return (
<Standard title={this.props.intl.formatMessage({ id: 'title.vmdetails' })}>
{/* eslint-disable-next-line react/jsx-no-undef */}
<VDCDetails vdcs={this.props.vdcs} VDC={this.props.VDC}/>
</Standard>
);
}
}
export default connect(
(store): {} => {
return {
vdcs: store.vdcs,
VDC: store.VDC,
};
},
(dispatch): {} => ({
actions: {
vdcDetailsLoad: (data): void => vdcDetailsLoad(data, dispatch),
getVdcs: (): void => getVdcs(dispatch),
},
}),
)(injectIntl(VdcDetailsPage));
Answer the question
In order to leave comments, you need to log in
In componentDidUpdate(), it is necessary to compare whether new props have arrived or whether the old ones are being updated.
Read more: https://ru.reactjs.org/docs/react-component.html#c...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question