0
router.replace({ pathname: path, query: query, params: params })

How can I replace this statement in RRDV6 and how can I pass params and query through navigate?

router.navigate(
  {
    pathname: path,
    search: createSearchParams(query).toString(),
  },
  { 
    replace: true,
    state: params
  }
)

Will this work or not?

Drew Reese
  • 165,259
  • 14
  • 153
  • 181
vaishnavi
  • 1
  • 3
  • FWIW though `router.navigate({ pathname: path, search: createSearchParams(query).toString() }, { replace: true, state: params })` should also work if you are using a data router, from what I understand of this [issue comment](https://github.com/remix-run/react-router/issues/9422#issuecomment-1301182219). I've not ever tried it, I suggest sticking to using the [`useNavigate`](https://reactrouter.com/en/main/hooks/use-navigate) hook as it is part of the public documented API. – Drew Reese Apr 27 '23 at 06:41
  • Hi @DrewReese I am using data router. I also have an another doubt did lazy loading prevents the back navigation in browser, because after clicking the back button of browser for two times only makes me to move previous page. – vaishnavi Apr 27 '23 at 07:02

0 Answers0