-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
WIP remove pending from store (2nd attempt) #6670
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
63ed328
9a21d5a
89a7c50
565a264
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 |
|---|---|---|
|
|
@@ -140,12 +140,12 @@ function RouteComp({ | |
| setActiveId: (id: string) => void | ||
| }) { | ||
| const styles = useStyles() | ||
| const matches = createMemo( | ||
| () => routerState().pendingMatches || routerState().matches, | ||
| ) | ||
| const match = createMemo(() => | ||
| routerState().matches.find((d) => d.routeId === route.id), | ||
| const matches = createMemo(() => | ||
| routerState().status === 'pending' | ||
| ? router().matchRoutes(router().latestLocation) | ||
| : routerState().matches, | ||
| ) | ||
| const match = createMemo(() => matches().find((d) => d.routeId === route.id)) | ||
|
|
||
| const param = createMemo(() => { | ||
| try { | ||
|
|
@@ -279,6 +279,14 @@ export const BaseTanStackRouterDevtoolsPanel = | |
|
|
||
| const [history, setHistory] = createSignal<Array<AnyRouteMatch>>([]) | ||
| const [hasHistoryOverflowed, setHasHistoryOverflowed] = createSignal(false) | ||
| const pendingMatches = createMemo(() => | ||
| routerState().status === 'pending' | ||
| ? router().matchRoutes(router().latestLocation) | ||
| : [], | ||
| ) | ||
| const displayedMatches = createMemo(() => | ||
| pendingMatches().length ? pendingMatches() : routerState().matches, | ||
| ) | ||
|
Comment on lines
+282
to
+289
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, locate the file
find . -type f -name "BaseTanStackRouterDevtoolsPanel.tsx" | head -5Repository: TanStack/router Length of output: 130 🏁 Script executed: # Check file size to determine how to read it
wc -l packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsxRepository: TanStack/router Length of output: 132 🏁 Script executed: # Read the relevant sections mentioned in the review
sed -n '280,295p' packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsxRepository: TanStack/router Length of output: 665 🏁 Script executed: # Also check lines 532 and 687-694
sed -n '530,535p' packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsxRepository: TanStack/router Length of output: 311 🏁 Script executed: sed -n '685,700p' packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsxRepository: TanStack/router Length of output: 743 🏁 Script executed: # Search for AnyRouteMatch type definition
rg "AnyRouteMatch" --type ts --type tsxRepository: TanStack/router Length of output: 86 🏁 Script executed: # Check the imports in the file to understand available types
head -50 packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsxRepository: TanStack/router Length of output: 1457 Tighten types for pending/displayed matches to keep strict TS guarantees. Explicit ♻️ Proposed fix- const pendingMatches = createMemo(() =>
+ const pendingMatches = createMemo<AnyRouteMatch[]>(() =>
routerState().status === 'pending'
? router().matchRoutes(router().latestLocation)
: [],
)
- const displayedMatches = createMemo(() =>
+ const displayedMatches = createMemo<AnyRouteMatch[]>(() =>
pendingMatches().length ? pendingMatches() : routerState().matches,
)- {displayedMatches().map((match: any, _i: any) => {
+ {displayedMatches().map((match) => {- {pendingMatches().find(
- (d: any) => d.id === activeMatch()?.id,
- )
+ {pendingMatches().find(
+ (d) => d.id === activeMatch()?.id,
+ )This addresses the coding guideline: 🤖 Prompt for AI Agents |
||
|
|
||
| createEffect(() => { | ||
| const matches = routerState().matches | ||
|
|
@@ -309,7 +317,7 @@ export const BaseTanStackRouterDevtoolsPanel = | |
|
|
||
| const activeMatch = createMemo(() => { | ||
| const matches = [ | ||
| ...(routerState().pendingMatches ?? []), | ||
| ...pendingMatches(), | ||
| ...routerState().matches, | ||
| ...routerState().cachedMatches, | ||
| ] | ||
|
|
@@ -521,10 +529,7 @@ export const BaseTanStackRouterDevtoolsPanel = | |
| </Match> | ||
| <Match when={currentTab() === 'matches'}> | ||
| <div> | ||
| {(routerState().pendingMatches?.length | ||
| ? routerState().pendingMatches | ||
| : routerState().matches | ||
| )?.map((match: any, _i: any) => { | ||
| {displayedMatches().map((match: any, _i: any) => { | ||
| return ( | ||
| <div | ||
| role="button" | ||
|
|
@@ -679,7 +684,7 @@ export const BaseTanStackRouterDevtoolsPanel = | |
| <div class={styles().matchDetailsInfoLabel}> | ||
| <div>State:</div> | ||
| <div class={styles().matchDetailsInfo}> | ||
| {routerState().pendingMatches?.find( | ||
| {pendingMatches().find( | ||
| (d: any) => d.id === activeMatch()?.id, | ||
| ) | ||
| ? 'Pending' | ||
|
|
||
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.
Grammar: add “the” for readability.
✏️ Suggested edit
📝 Committable suggestion
🤖 Prompt for AI Agents