mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-01-24 02:09:52 +00:00
feat: more efficient filter with use memo
This commit is contained in:
parent
f3b985713a
commit
c47de2c6d1
@ -1,6 +1,6 @@
|
|||||||
import { Checkbox, DropdownMenu, Text } from '@status-im/components'
|
import { Checkbox, DropdownMenu, Text } from '@status-im/components'
|
||||||
import { OptionsIcon, SortIcon } from '@status-im/icons'
|
import { OptionsIcon, SortIcon } from '@status-im/icons'
|
||||||
import { useEffect, useState } from 'react'
|
import { useMemo, useState } from 'react'
|
||||||
import { YStack, XStack, Stack } from 'tamagui'
|
import { YStack, XStack, Stack } from 'tamagui'
|
||||||
|
|
||||||
import ValidatorProfile from '../../../components/General/ValidatorProfile'
|
import ValidatorProfile from '../../../components/General/ValidatorProfile'
|
||||||
@ -63,18 +63,15 @@ type ManagementTableProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ManagementTable = ({ tab }: ManagementTableProps) => {
|
const ManagementTable = ({ tab }: ManagementTableProps) => {
|
||||||
const [currentValidators, setCurrentValidators] = useState(validators)
|
|
||||||
const [searchValue, setSearchValue] = useState('')
|
const [searchValue, setSearchValue] = useState('')
|
||||||
|
|
||||||
useEffect(() => {
|
const filteredValidators = useMemo(() => {
|
||||||
setCurrentValidators(
|
return validators
|
||||||
validators
|
|
||||||
.filter(validator => validator.status === tab)
|
.filter(validator => validator.status === tab)
|
||||||
.filter(
|
.filter(
|
||||||
validator =>
|
validator =>
|
||||||
validator.number.toString().includes(searchValue) ||
|
validator.number.toString().includes(searchValue) ||
|
||||||
validator.address.includes(searchValue),
|
validator.address.includes(searchValue),
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}, [tab, searchValue])
|
}, [tab, searchValue])
|
||||||
|
|
||||||
@ -172,7 +169,7 @@ const ManagementTable = ({ tab }: ManagementTableProps) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{currentValidators.map((validator, index) => (
|
{filteredValidators.map((validator, index) => (
|
||||||
<tr key={index}>
|
<tr key={index}>
|
||||||
<td>
|
<td>
|
||||||
<Checkbox id={index.toString()} variant="outline" />
|
<Checkbox id={index.toString()} variant="outline" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user