diff --git a/client/src/components/Tree/ObjectTree.tsx b/client/src/components/Tree/ObjectTree.tsx index 9224e9d..4109f00 100644 --- a/client/src/components/Tree/ObjectTree.tsx +++ b/client/src/components/Tree/ObjectTree.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useEffect, useMemo, useState } from 'react' import useSWR from 'swr' import { fetcher } from '../../http/axiosInstance' import { BASE_URL } from '../../constants' @@ -118,15 +118,25 @@ const ObjectList = ({ } ) + const navLinks = useMemo(() => ( + Array.isArray(data) ? data.map((type) => ( + setCurrentObjectId(map_id, type.object_id)} /> + )) : null + ), [data, map_id]); + return ( - { - setSelectedObjectType(map_id, id) - }} rightSection={} p={0} label={`${label} ${count ? `(${count})` : ''}`}> - {Array.isArray(data) && data.map((type) => ( - setCurrentObjectId(map_id, type.object_id)} /> - ))} + setSelectedObjectType(map_id, id)} rightSection={} p={0} label={`${label} ${count ? `(${count})` : ''}`}> + {navLinks} - ) + ); + + // return ( + // { setSelectedObjectType(map_id, id) }} rightSection={} p={0} label={`${label} ${count ? `(${count})` : ''}`}> + // {Array.isArray(data) && data.map((type) => ( + // setCurrentObjectId(map_id, type.object_id)} /> + // ))} + // + // ) } export default ObjectTree \ No newline at end of file