Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

reactjs - History doesn't update on url change using react-router-dom

So the problem was that when i tried to go back using browser native back, as well as history.back(), history.push() and history.replace() button it took me to the wrong path, so instead of going to the previous page i'd gotten into previous website, like completely different one.

To navigate through the pages i was using useHistory hook.

question from:https://stackoverflow.com/questions/66051779/history-doesnt-update-on-url-change-using-react-router-dom

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So to do this you'd need to pass optional argument of state into the function call so that

history.replace('some-url')

will be changed to, for me at least

history.reaplce('some-url', '/')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...