-
-
Notifications
You must be signed in to change notification settings - Fork 643
refactor(Example): TabsContainer and StackContainer refactor #3925
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
base: main
Are you sure you want to change the base?
Changes from all commits
e0bb90f
1d462c0
9d9912e
0cca1e0
88a0d86
75b570c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React, { useMemo } from 'react'; | ||
| import type { StackRouteConfig } from '../stack'; | ||
| import type { TabRouteConfig } from '../tabs'; | ||
|
|
||
| export const useComponentsByName = ( | ||
| routeConfigs: StackRouteConfig[] | TabRouteConfig[], | ||
| ) => { | ||
| return useMemo(() => { | ||
| const map = new Map<string, React.ComponentType>(); | ||
|
|
||
| for (const config of routeConfigs) { | ||
| map.set(config.name, config.Component); | ||
| } | ||
|
|
||
| return map; | ||
| }, [routeConfigs]); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| import type { TabRoute, TabsNavigationMethods } from './TabsContainer.types'; | ||
| import React from 'react'; | ||
|
|
||
| export type TabsContainerItemProps = { | ||
| route: TabRoute; | ||
| navMethods: TabsNavigationMethods; | ||
| isSelected: boolean; | ||
| pendingForUpdate: boolean; | ||
| } | ||
|
|
||
| Component: React.ComponentType; | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -135,8 +135,10 @@ function tabsActionSetOptionsHandler( | |||||||||
| } | ||||||||||
|
|
||||||||||
| function createTabRouteFromConfig(config: TabRouteConfig): TabRoute { | ||||||||||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||||||||||
| const { Component, ...rest } = config; | ||||||||||
|
Comment on lines
+138
to
+139
|
||||||||||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | |
| const { Component, ...rest } = config; | |
| const { Component, ...rest } = config; | |
| void Component; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid the
eslint-disablehere; it’s better to omitComponentwithout disabling lint (e.g., rename the destructured field to an ignored identifier per lint rules, or explicitly consume it) while still returning...rest.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave it in the current form, because it's on the example app's side and we also did the same in other places.