Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Narrow-down SideMenu props and memoize #5388

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ const EdgeAppStack = () => {
const EdgeApp = () => {
return (
<Drawer.Navigator
drawerContent={props => SideMenu(props)}
drawerContent={({ navigation }) => <SideMenu navigation={navigation} />}
initialRouteName="edgeAppStack"
screenOptions={{
drawerPosition: 'right',
Expand Down
16 changes: 10 additions & 6 deletions src/components/themed/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { lstrings } from '../../locales/strings'
import { getDefaultFiat } from '../../selectors/SettingsSelectors'
import { config } from '../../theme/appConfig'
import { useDispatch, useSelector } from '../../types/reactRedux'
import { DrawerSceneProps, NavigationBase } from '../../types/routerTypes'
import { NavigationBase } from '../../types/routerTypes'
import { parseDeepLink } from '../../util/DeepLinkParser'
import { getDisplayUsername } from '../../util/utils'
import { IONIA_SUPPORTED_FIATS } from '../cards/VisaCardCard'
Expand All @@ -44,11 +44,13 @@ import { EdgeText } from './EdgeText'
const footerGradientStart = { x: 0, y: 0 }
const footerGradientEnd = { x: 0, y: 0.75 }

export function SideMenu(props: DrawerContentComponentProps) {
// Fix this type assertion (seems like DrawerContentComponentProps works just
// fine as NavigationBase?)
const { navigation } = props as any as DrawerSceneProps<'edgeAppStack'>
const navigationBase = props.navigation as any as NavigationBase
interface Props {
navigation: DrawerContentComponentProps['navigation']
}

export function SideMenuComponent(props: Props) {
const { navigation } = props
const navigationBase = navigation as any as NavigationBase
const isDrawerOpen = useDrawerStatus() === 'open'

const dispatch = useDispatch()
Expand Down Expand Up @@ -385,6 +387,8 @@ export function SideMenu(props: DrawerContentComponentProps) {
)
}

export const SideMenu = React.memo(SideMenuComponent)

/**
* Given a list of users from the core,
* remove the given user, then organize the 3 most recent users,
Expand Down
Loading