Skip to content

bug(react): navigation source resolves stale route closures #373

Description

@vamgan

Summary

useAskableNavigationSource() memoizes its source with an empty dependency array, permanently freezing the first render's getPath, getTitle, getParams, maxHistory, describe, and kind values.

The documented React Router/Next.js examples create closures over changing router state. pathname changes trigger notifyChanged(), but source resolution still calls the initial closure and can report the previous route.

Evidence

packages/react/src/useAskableNavigationSource.ts creates the source with useMemo(..., []) around lines 77–80 while notifying on pathname around lines 85–87.

Proposed fix

Use latest-value refs behind stable callbacks, or rebuild/replace the source when relevant options change. Preserve one registration and avoid duplicate navigation history entries.

Acceptance criteria

  • Rerendering from /first to /second resolves /second
  • Updated params, title, callbacks, history limit, description, and kind take effect
  • Source registration is not duplicated
  • React Router and Next.js patterns receive regression tests
  • Similar empty-dependency source factories are audited for stale options

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: reactReact adapter workbugSomething isn't workingpriority: highMust land before broader feature work / correctness-sensitive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions