I have react page with table. Table has a column with hyperlink when I click on a particular hyperlink new page open with details about the clicked hyperlink or row.
<Route exact path="/employeedetails" element={<EmployeeDetails />} />
I want to avoid reloading Employee Details page when user refresh or press F5. Or How can I capture a refresh event and call the React component.
2
Answers
I had experienced same problem. Here is the some of solutions but there is no perfect way to block the refreshing as I know.
It will perfectly block the F5, if not, check the keyCode.
But, when you click the browser refresh button, it will be refreshed if there are routing history.
You can use the window
beforeunload
event:You can know more about that event click here