Search code examples
reactjsreact-routerreact-router-dom

react-router changing route doesn't update the page in prod (worked in dev)


After I build and serve my CRA project, the route changes doesn't update the page at all. It does working fine in dev mode tho.

dependencies:

    "react": "^18.2.0",
    "react-router-dom": "^6.12.1",

The page does render if I refresh the page tho.


Solution

  • After a long search, I found that updating the react-router-dom to version 6.21.0 fixed the problem. here is the git comment link for the reference: https://github.com/remix-run/react-router/issues/10579#issuecomment-1584119970

    - "react-router-dom": "^6.12.1",
    + "react-router-dom": "^6.21.0",