location.state becomes null when I set it for the second time

53 views Asked by At

I have a sig-in sign-up scenario in my website, in which when a user lands in page1, it should be singed-in, so it would redirected to sign-in page by a command like below in page1.js

history.push({
       pathname: '/login-page',
       state: { from: '/page1' }
   });

Obviously, if the user has not signed-up yet, it would again redicred to sign-up page from sig-in page by a command which retrieve pathname from above state.from

Now in sign-up page the user could return back to sign-in page

history.push({
       pathname: '/login-page',
       state: { from: from }
   });

which again from retrvied from state.from, the problem is that all these states wol fine till sign-up page, but when the user land in sign-in page the location.state is always undefined while I have used explicitly above command with the path name set to '/login-page'. Does anyone have any clue why this happens?

0

There are 0 answers