diff --git a/src/pages/ValidatorManagement/ManagementTable/ManagementTable.tsx b/src/pages/ValidatorManagement/ManagementTable/ManagementTable.tsx index 7e2f018a..be0c9deb 100644 --- a/src/pages/ValidatorManagement/ManagementTable/ManagementTable.tsx +++ b/src/pages/ValidatorManagement/ManagementTable/ManagementTable.tsx @@ -1,6 +1,6 @@ import { Checkbox, DropdownMenu, Text } from '@status-im/components' import { OptionsIcon, SortIcon } from '@status-im/icons' -import { useEffect, useState } from 'react' +import { useMemo, useState } from 'react' import { YStack, XStack, Stack } from 'tamagui' import ValidatorProfile from '../../../components/General/ValidatorProfile' @@ -63,19 +63,16 @@ type ManagementTableProps = { } const ManagementTable = ({ tab }: ManagementTableProps) => { - const [currentValidators, setCurrentValidators] = useState(validators) const [searchValue, setSearchValue] = useState('') - useEffect(() => { - setCurrentValidators( - validators - .filter(validator => validator.status === tab) - .filter( - validator => - validator.number.toString().includes(searchValue) || - validator.address.includes(searchValue), - ), - ) + const filteredValidators = useMemo(() => { + return validators + .filter(validator => validator.status === tab) + .filter( + validator => + validator.number.toString().includes(searchValue) || + validator.address.includes(searchValue), + ) }, [tab, searchValue]) const changeSearchValue = (value: string) => { @@ -172,7 +169,7 @@ const ManagementTable = ({ tab }: ManagementTableProps) => {
- {currentValidators.map((validator, index) => ( + {filteredValidators.map((validator, index) => (