mirror of
https://github.com/openziti/zrok.git
synced 2025-08-23 05:30:46 +02:00
fix for bad network requests before component ready
This commit is contained in:
@@ -9,6 +9,7 @@ const MetricsTab = (props) => {
|
|||||||
const [metrics1, setMetrics1] = useState(buildMetrics([]));
|
const [metrics1, setMetrics1] = useState(buildMetrics([]));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if(props.share.token) {
|
||||||
metadata.getShareMetrics(props.share.token)
|
metadata.getShareMetrics(props.share.token)
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
setMetrics30(buildMetrics(resp.data));
|
setMetrics30(buildMetrics(resp.data));
|
||||||
@@ -21,11 +22,13 @@ const MetricsTab = (props) => {
|
|||||||
.then(resp => {
|
.then(resp => {
|
||||||
setMetrics1(buildMetrics(resp.data));
|
setMetrics1(buildMetrics(resp.data));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}, [props.share]);
|
}, [props.share]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let mounted = true;
|
let mounted = true;
|
||||||
let interval = setInterval(() => {
|
let interval = setInterval(() => {
|
||||||
|
if(props.share.token) {
|
||||||
metadata.getShareMetrics(props.share.token)
|
metadata.getShareMetrics(props.share.token)
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
if(mounted) {
|
if(mounted) {
|
||||||
@@ -34,12 +37,17 @@ const MetricsTab = (props) => {
|
|||||||
});
|
});
|
||||||
metadata.getShareMetrics(props.share.token, {duration: "168h"})
|
metadata.getShareMetrics(props.share.token, {duration: "168h"})
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
|
if(mounted) {
|
||||||
setMetrics7(buildMetrics(resp.data));
|
setMetrics7(buildMetrics(resp.data));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
metadata.getShareMetrics(props.share.token, {duration: "24h"})
|
metadata.getShareMetrics(props.share.token, {duration: "24h"})
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
|
if(mounted) {
|
||||||
setMetrics1(buildMetrics(resp.data));
|
setMetrics1(buildMetrics(resp.data));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
return () => {
|
return () => {
|
||||||
mounted = false;
|
mounted = false;
|
||||||
|
Reference in New Issue
Block a user