diff --git a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshot.tsx b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshot.tsx index c17c73cb08..f501fd77bf 100644 --- a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshot.tsx +++ b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshot.tsx @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React, { useEffect, useState } from 'react'; +import React from 'react'; import { Box, Grid, MenuItem, Select } from '@material-ui/core'; import { useApi, storageApiRef } from '@backstage/core-plugin-api'; import useAsync from 'react-use/lib/useAsync'; @@ -43,19 +43,17 @@ export const DashboardSnapshot = ({ guid, name, permalink }: Props) => { storageApi.observe$(guid), storageApi.snapshot(guid), ); - const [newDuration, setNewDuration] = useState(2592000000); - - useEffect(() => { - if (storageSnapshot.value) setNewDuration(Number(storageSnapshot.value)); - }, [guid, storageSnapshot]); const { value, loading, error } = useAsync(async (): Promise< DashboardSnapshotSummary | undefined > => { const dashboardObject: Promise = - newRelicDashboardAPI.getDashboardSnapshot(guid, newDuration); + newRelicDashboardAPI.getDashboardSnapshot( + guid, + storageSnapshot.value || 2592000000, + ); return dashboardObject; - }, [guid, newDuration]); + }, [guid, storageSnapshot.value]); if (loading) { return ; @@ -77,9 +75,9 @@ export const DashboardSnapshot = ({ guid, name, permalink }: Props) => { action={