File tree Expand file tree Collapse file tree
apps/src/shared/gamma/containers/tabs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,7 +84,27 @@ export function TabsContainer(props: TabsContainerProps) {
8484 const pendingForUpdate =
8585 route . routeKey === tabsNavState . suggestedState . selectedRouteKey ;
8686
87- return < TabsContainerItem key = { route . routeKey } route = { route } navMethods = { navMethods } isSelected = { isSelected } pendingForUpdate = { pendingForUpdate } />
87+ const matchingConfig = routeConfigs . find (
88+ config => config . name === route . routeKey ,
89+ ) ;
90+ if ( ! matchingConfig ) {
91+ throw new Error (
92+ `[Tabs] None config matches the "${ route . routeKey } " routeKey` ,
93+ ) ;
94+ }
95+
96+ const Component = matchingConfig . Component ;
97+
98+ return (
99+ < TabsContainerItem
100+ key = { route . routeKey }
101+ route = { route }
102+ navMethods = { navMethods }
103+ isSelected = { isSelected }
104+ pendingForUpdate = { pendingForUpdate }
105+ Component = { Component }
106+ />
107+ ) ;
88108 } ) }
89109 </ Tabs . Host >
90110 ) ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export type TabRouteConfig = {
2727/**
2828 * Runtime instance of a tab route. Created from a TabRouteConfig blueprint.
2929 */
30- export type TabRoute = TabRouteConfig & {
30+ export type TabRoute = Omit < TabRouteConfig , 'Component' > & {
3131 routeKey : string ;
3232} ;
3333
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ function TabsContainerItemImpl(props: TabsContainerItemProps) {
3737 { ...nativeOptions }
3838 screenKey = { screenKey } >
3939 < TabsNavigationContext value = { tabsNavigationContext } >
40- { getContent ( props . route . Component , safeAreaConfiguration ) }
40+ { getContent ( props . Component , safeAreaConfiguration ) }
4141 </ TabsNavigationContext >
4242 </ Tabs . Screen >
4343 ) ;
Original file line number Diff line number Diff line change @@ -5,5 +5,6 @@ export type TabsContainerItemProps = {
55 navMethods : TabsNavigationMethods ;
66 isSelected : boolean ;
77 pendingForUpdate : boolean ;
8+ Component : React . ComponentType ;
89}
910
Original file line number Diff line number Diff line change @@ -135,8 +135,10 @@ function tabsActionSetOptionsHandler(
135135}
136136
137137function createTabRouteFromConfig ( config : TabRouteConfig ) : TabRoute {
138+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
139+ const { Component, ...rest } = config ;
138140 return {
139- ...config ,
141+ ...rest ,
140142 // Tab names are required to be unique (enforced by useSanitizeRouteConfigs),
141143 // so the name itself serves as a stable unique key.
142144 routeKey : config . name ,
@@ -205,4 +207,3 @@ function navStateWithConfirmedState(
205207 suggestedState : state . suggestedState ,
206208 } ;
207209}
208-
You can’t perform that action at this time.
0 commit comments