fix(react-router): avoid throwing in useMatch selector#7595
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR refactors client-side return logic in ChangesuseMatch selector fallback handling
Sequence Diagram(s)sequenceDiagram
participant useMatch
participant useStore
participant selector
participant matchStore
useMatch->>useStore: useStore(matchStore ?? dummyStore, selector)
useStore->>selector: execute selector (apply dummyStore fallback)
selector->>useStore: selected value or dummyStore
useStore->>useMatch: matchSelection
useMatch->>useMatch: if matchSelection !== dummyStore -> return selection
useMatch->>useMatch: else -> opts.shouldThrow -> invariant/return undefined
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit e99d31b
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview2 package(s) bumped directly, 7 bumped as dependents. 🟩 Patch bumps
|
Bundle Size Benchmarks
Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better. |
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud is proposing a fix for your failed CI:
We removed the redundant as any cast on the return matchSelection statement in useMatch.tsx, which was flagged as an error by @typescript-eslint/no-unnecessary-type-assertion. The assertion was a no-op because the useStore selector already infers matchSelection as any at that point, so the cast did not change the type. This change resolves the single ESLint error that caused the @tanstack/react-router:test:eslint task to fail.
Tip
✅ We verified this fix by re-running @tanstack/react-router:test:eslint.
diff --git a/packages/react-router/src/useMatch.tsx b/packages/react-router/src/useMatch.tsx
index 32fba9bc..6c1d0342 100644
--- a/packages/react-router/src/useMatch.tsx
+++ b/packages/react-router/src/useMatch.tsx
@@ -184,7 +184,7 @@ export function useMatch<
)
if (matchSelection !== dummyStore) {
- return matchSelection as any
+ return matchSelection
}
if (opts.shouldThrow ?? true) {
Or Apply changes locally with:
npx nx-cloud apply-locally zIOc-9rVw
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
Summary
Verification
Summary by CodeRabbit
Refactor
Tests