From 2224367f9b87de3ecb4ed7f7980a27767aef92d5 Mon Sep 17 00:00:00 2001 From: Romuald Lemesle Date: Wed, 28 Aug 2024 13:55:26 +0200 Subject: [PATCH] [frontend] Remove double fetch (#1184) Co-authored-by: Guillaume Paris --- .../components/atomic_testings/InjectList.tsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/openbas-front/src/admin/components/atomic_testings/InjectList.tsx b/openbas-front/src/admin/components/atomic_testings/InjectList.tsx index 4de2085397..f79ab871f2 100644 --- a/openbas-front/src/admin/components/atomic_testings/InjectList.tsx +++ b/openbas-front/src/admin/components/atomic_testings/InjectList.tsx @@ -1,4 +1,4 @@ -import React, { CSSProperties, FunctionComponent, useEffect, useState } from 'react'; +import React, { CSSProperties, FunctionComponent, useMemo, useState } from 'react'; import { makeStyles } from '@mui/styles'; import { List, ListItem, ListItemButton, ListItemIcon, ListItemText } from '@mui/material'; import { useFormatter } from '../../../components/i18n'; @@ -84,18 +84,12 @@ const InjectList: FunctionComponent = ({ sorts: initSorting('inject_updated_at', 'DESC'), })); - // Fetch injects on initial render and when pagination input changes - useEffect(() => { - fetchInjects(searchPaginationInput) - .then((response) => setInjects(response.data.content)); - }, [fetchInjects, searchPaginationInput]); - // Headers - const headers = [ + const headers = useMemo(() => [ { field: 'inject_type', label: 'Type', - isSortable: true, + isSortable: false, value: (injectDto: InjectResultDTO) => { if (injectDto.inject_injector_contract) { return ( @@ -120,9 +114,9 @@ const InjectList: FunctionComponent = ({ { field: 'inject_status', label: 'Status', - isSortable: true, + isSortable: false, value: (injectDto: InjectResultDTO) => { - return (); + return (); }, }, { @@ -149,7 +143,7 @@ const InjectList: FunctionComponent = ({ isSortable: true, value: (injectDto: InjectResultDTO) => nsdt(injectDto.inject_updated_at), }, - ]; + ], []); return ( <>