Skip to content

Commit

Permalink
Merge pull request #5388 from EdgeApp/sam/sidemen-props
Browse files Browse the repository at this point in the history
Narrow-down SideMenu props and memoize
  • Loading branch information
samholmes authored Dec 11, 2024
2 parents 451bde1 + d0eb9ce commit 294fc8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
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

0 comments on commit 294fc8f

Please sign in to comment.