Skip to content

[v2] avoid recreating browser router on every app render #1155

@nischal-shetty2

Description

@nischal-shetty2

right now createBrowserRouter() is being called inside the App component body, which means a new router instance gets created on every render.

since App re-renders on state, context, and translation changes, this causes the router to be recreated repeatedly. react router expects the router instance to be stable, and recreating it can reset internal navigation state, interrupt pending fetchers, and potentially cause subtle routing bugs.

the router should be memoized with the correct dependencies or refactored so it is created once and remains stable across renders.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomersv2Related to the redesigned v2 release

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions