Skip to content

Migrate to unstable_useRouterState hook#244

Merged
brophdawg11 merged 3 commits into
mainfrom
brophdawg11/use-router-state
May 15, 2026
Merged

Migrate to unstable_useRouterState hook#244
brophdawg11 merged 3 commits into
mainfrom
brophdawg11/use-router-state

Conversation

@brophdawg11
Copy link
Copy Markdown
Contributor

@brophdawg11 brophdawg11 commented May 13, 2026

Summary

  • Migrates the app to the new unstable_useRouterState hook from remix-run/react-router#15038, consolidating useLocation / useParams / useNavigation calls into a single hook.
  • useMatches calls in app/hooks/use-doc.ts and app/modules/docsearch.tsx are intentionally left alone — the new hook's matches is typed as Omit<UIMatch, "data" | "loaderData">, and both call sites read loaderData.
  • The custom ~/hooks/use-navigation wrapper now uses useRouterState internally, so docs-menu/menu.tsx and version-select.tsx pick up the change transparently.

Test plan

  • pnpm run typecheck passes
  • pnpm run test passes (31/31)
  • Manual: verify active/pending link styles in the docs sidebar and <VersionSelect> popup
  • Manual: verify color scheme toggle still applies optimistic updates on submit
  • Manual: verify <DetailsMenu> closes on navigation and on form submission
  • Manual: verify the doc 404 ErrorBoundary still renders the splat param

🤖 Generated with Claude Code

Replaces useLocation/useParams/useNavigation calls with the consolidated
unstable_useRouterState hook from remix-run/react-router#15038. useMatches
calls that read loaderData are left in place since the new hook's matches
omit data fields.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread app/hooks/use-navigation.ts Outdated
}

return navigation;
return { isActive, isPending };
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook probably could use some reworking now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa, this hook is kind of crazy. Yeah I imagine it can, I imagine it's original purpose is quite different from what's even needed now

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@brophdawg11 brophdawg11 marked this pull request as ready for review May 14, 2026 15:42
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@brookslybrand brookslybrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! Looks great. Pulled down and tested all the interactions this PR touched. Nice cleanup overall

@brophdawg11 brophdawg11 merged commit e2a8412 into main May 15, 2026
1 check passed
@brophdawg11 brophdawg11 deleted the brophdawg11/use-router-state branch May 15, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants