next.js
73c9a93f - refactor: rename useRoute to unstable_useRoute with effect-phase restriction

Commit
108 days ago
refactor: rename useRoute to unstable_useRoute with effect-phase restriction Based on feedback from Andrew Clark, this change: 1. Renames useRoute() to unstable_useRoute() to mark it as experimental 2. Changes return type from string to () => string (getter function) 3. Restricts route data access to effect phase only (useEffect, useLayoutEffect, event handlers) The getter function throws an error in development if called during render. This prevents route structure from leaking into rendering decisions, which is important for future flexibility. Updated test component to use the new getter pattern with useState and useEffect.
Author
Committer
Parents
Loading