Skip to content

Commit

Permalink
Move useFooterAccordionEvents hook to a Discreet component
Browse files Browse the repository at this point in the history
This Discreet component is a leaf component (it has no children), and
therefore it is cheap to re-render.
  • Loading branch information
samholmes committed Jan 26, 2024
1 parent 8bacd3f commit 839d82a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
9 changes: 9 additions & 0 deletions src/components/Discreet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useFooterAccordionEvents } from '../state/SceneFooterState'

export function Discreet() {
// Register footer accordion events
useFooterAccordionEvents()

// No child component
return null
}
40 changes: 21 additions & 19 deletions src/components/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import { RewardsCardDashboardScene as RewardsCardListSceneComponent } from '../p
import { RewardsCardWelcomeScene as RewardsCardWelcomeSceneComponent } from '../plugins/gui/scenes/RewardsCardWelcomeScene'
import { SepaFormScene } from '../plugins/gui/scenes/SepaFormScene'
import { defaultAccount } from '../reducers/CoreReducer'
import { useFooterAccordionEvents } from '../state/SceneFooterState'
import { useDispatch, useSelector } from '../types/reactRedux'
import { AppParamList, NavigationBase } from '../types/routerTypes'
import { logEvent } from '../util/tracking'
import { Discreet } from './Discreet'
import { ifLoggedIn } from './hoc/IfLoggedIn'
import { useBackEvent } from './hoc/useBackEvent'
import { BackButton } from './navigation/BackButton'
Expand Down Expand Up @@ -235,9 +235,6 @@ export const Main = () => {
const [legacyLanding, setLegacyLanding] = React.useState<boolean | undefined>(isMaestro() ? false : undefined)
const [hasInitialScenesLoaded, setHasInitialScenesLoaded] = React.useState(false)

// Register footer accordion events
useFooterAccordionEvents()

// Match react navigation theme background with the patina theme
const reactNavigationTheme = React.useMemo(() => {
return {
Expand Down Expand Up @@ -270,21 +267,26 @@ export const Main = () => {
'setLegacyLanding'
)

return legacyLanding == null ? (
<LoadingSplashScreen />
) : (
<NavigationContainer theme={reactNavigationTheme}>
<Stack.Navigator
initialRouteName={ENV.USE_WELCOME_SCREENS && !legacyLanding ? 'gettingStarted' : 'login'}
screenOptions={{
headerShown: false
}}
>
<Stack.Screen name="edgeApp" component={EdgeApp} />
<Stack.Screen name="gettingStarted" component={GettingStartedScene} />
<Stack.Screen name="login" component={LoginScene} options={{ animationEnabled: hasInitialScenesLoaded }} />
</Stack.Navigator>
</NavigationContainer>
return (
<>
{legacyLanding == null ? (
<LoadingSplashScreen />
) : (
<NavigationContainer theme={reactNavigationTheme}>
<Stack.Navigator
initialRouteName={ENV.USE_WELCOME_SCREENS && !legacyLanding ? 'gettingStarted' : 'login'}
screenOptions={{
headerShown: false
}}
>
<Stack.Screen name="edgeApp" component={EdgeApp} />
<Stack.Screen name="gettingStarted" component={GettingStartedScene} />
<Stack.Screen name="login" component={LoginScene} options={{ animationEnabled: hasInitialScenesLoaded }} />
</Stack.Navigator>
</NavigationContainer>
)}
<Discreet />
</>
)
}

Expand Down

0 comments on commit 839d82a

Please sign in to comment.