0

After upgrading to react router v6.7.0, I'm facing this issue. I'm passing the state in navigate but in the target page i get the state object first time, on rerenders state is null.

And navigate(-1) also not taking to previous page, remaining on same page.

navigate('traget url', {state:"mystatevalue" });

In the target page reading the state using uselocation.

const location= useLocation(); console.log(location.state);

//First time I get mystatevalue // 2nd and 3rd render null

const location= useLocation(); console.log(location.state);

//First time I get mystatevalue // 2nd and 3rd render null.

Drew Reese
  • 165,259
  • 14
  • 153
  • 181
  • Hi, please [edit](https://stackoverflow.com/posts/75354421/edit) your question and add your code within code blocks, see [how to format](https://stackoverflow.com/help/formatting) for more information – RubenSmn Feb 05 '23 at 18:51

0 Answers0