feat: map content with useMemo

This commit is contained in:
RadoslavDimchev 2023-10-19 08:58:28 +03:00
parent 8cb990c072
commit aafb57d2b8
1 changed files with 27 additions and 24 deletions

View File

@ -2,23 +2,30 @@ import { Tabs } from '@status-im/components'
import { Stack } from 'tamagui' import { Stack } from 'tamagui'
import ValidatorsList from './ValidatorsList' import ValidatorsList from './ValidatorsList'
import { useMemo } from 'react'
const VALIDATOR_TABS = [
{
label: 'Active',
value: 'active',
},
{
label: 'Pending',
value: 'pending',
},
{
label: 'Inactive',
value: 'inactive',
},
]
const ValidatorsTabs = () => { const ValidatorsTabs = () => {
const VALIDATOR_TABS = useMemo(
() => [
{
label: 'Active',
value: 'active',
children: <ValidatorsList />,
},
{
label: 'Pending',
value: 'pending',
children: <ValidatorsList />,
},
{
label: 'Inactive',
value: 'inactive',
children: <ValidatorsList />,
},
],
[],
)
return ( return (
<Tabs defaultValue="active"> <Tabs defaultValue="active">
<Stack style={{ cursor: 'pointer', width: 'fit-content' }}> <Stack style={{ cursor: 'pointer', width: 'fit-content' }}>
@ -30,15 +37,11 @@ const ValidatorsTabs = () => {
))} ))}
</Tabs.List> </Tabs.List>
</Stack> </Stack>
<Tabs.Content value="active" style={{ marginTop: '8px' }}> {VALIDATOR_TABS.map(tab => (
<ValidatorsList /> <Tabs.Content value={tab.value} style={{ marginTop: '8px' }}>
</Tabs.Content> {tab.children}
<Tabs.Content value="pending"> </Tabs.Content>
<ValidatorsList /> ))}
</Tabs.Content>
<Tabs.Content value="inactive">
<ValidatorsList />
</Tabs.Content>
</Tabs> </Tabs>
) )
} }