.claude/skills/tanstack-router-stability-spfx/SKILL.md
Stable singleton pattern for TanStack Router v1 preventing route-tree recreation and UI freezes on AppContext changes in SPFx
npx skillsauth add RMF112018/Project-Controls TanStack Router Stability SPFxInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Activation Implementing, modifying, or debugging TanStack Router provider, route guards, navigation components, ProjectPicker, adapter hooks, or any scenario where navigation freezes after dashboard load or project switch.
Protocol
useRef in router.tsx with static values only (queryClient, dataService). NEVER recreate on dynamic value changes.React.useEffect -> router.update({ context: { currentUser, selectedProject, isFeatureEnabled, scope } }) for all dynamic values. RouterProvider context={} syncs the React tree.useAppNavigate returns a ref-stable callback (identity never changes). useAppLocation returns a useMemo-stabilised { pathname, search }. useAppParams returns useMemo-stabilised params with JSON.stringify dep.handleSelect MUST close popover (setIsOpen(false)) and clear query BEFORE firing context mutation. Context mutation wrapped in React.startTransition(() => onSelect(project)).useMemo to avoid unnecessary router.update() calls.tsc --noEmit + jest --no-coverage + update CLAUDE.md S4 and S16.6 Critical Flows Guaranteed Stable
startTransition); router updates in-place via router.update()useTransitionNavigate returns a stable callback; all navigations wrapped in startTransitionuseAppLocation returns memoised { pathname, search }; NavigationSidebar active-state checks only re-run when path actually changesuseAppParams returns memoised params; downstream components (LeadDetail, GoNoGo) don't re-render on unrelated router state changesrouter.update() context merge; guards see latest isFeatureEnabled without router recreationuseTransitionNavigate / useAppLocation; no unnecessary re-rendersManual Test Steps
/operations/monthly-review) -> verify no blank screen or remount/lead/:id) -> verify params load correctlyReference
CLAUDE.md S4 (Router Stability Rule), S16 (Active Pitfalls)PERFORMANCE_OPTIMIZATION_GUIDE.md S4 (React 18 & Context Rules)SECURITY_PERMISSIONS_GUIDE.md S1 (TanStack Router guard enforcement)react-context-and-concurrent skill (context splitting complement)databases
Query-key stability, default options, and virtualization threshold enforcement
tools
High-ROI bundle reduction, profiler-driven diagnostics, and verification for SPFx + Vite environments
databases
Branching what-if scenarios and Monte Carlo risk simulation with tornado/S-curve visualization
development
Extreme-scale optimization for 10k+ activity schedules under bundle and React 18 constraints