In React, I want to do something only if back button is clicked but what actually happening is it gets invoked on both back and forward buttons on the browser.
This is what I tried, but it gets called on both back and forward button clicks
window.onpopstate = () => {
someFunction();
};
Is there a way to check if it is back button only or forward button only?