Reactjs browser back button functionality | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Reactjs browser back button functionality

I have created one website using react now in homepage all sections are from api only footer is static one so when I navigate to next page and if I came back to homepage footer is loads first ideally it should go to the previous section which I was clicked ..how to override this functionality plz any one help me and thanks in advance

11th Jun 2021, 6:56 AM
Krishnaji Kulkarni
Krishnaji Kulkarni - avatar
2 Answers
+ 3
you may use history.back() to navigate back with js.. no idea if you can use with react..try it once and leme know..
11th Jun 2021, 7:04 AM
Prashanth Kumar
Prashanth Kumar - avatar
+ 1
Krishnaji Kulkarni you can use react-router-dom to handle the url routing. Here i used stackblitz to rebuild a sample site similar to what you described with multiple pages nav links and simulated api fetch on each page load. Webpage: https://react-router-dom-basix-multi-page-example.stackblitz.io Reactjs codes: https://stackblitz.com/edit/react-router-dom-basix-multi-page-example?file=src/BasicRoutingEx1.js
12th Jun 2021, 2:25 PM
Calviղ
Calviղ - avatar