Inside useEffect , I am calling window.location.replace
and once that completes , I need to fetch a value from cookie
I have used await , but didn’t worked
Inside useEffect , I am calling window.location.replace
and once that completes , I need to fetch a value from cookie
I have used await , but didn’t worked
2
Answers
There’s no way to do that.
When
window.location.replace
completes, the rest of that function will not run since it’s been unloaded, as you’ve navigated elsewhere.You can not do it directly on the page where you call
window.location.replace
, but if you have a control over who calling it and you navigating to the same app, you can use a trick:SessionStorage
right before callingwindow.location.replace