I am using the Functional component for React Project. I like to add functionality like <prompt /> that is if the user accidentally presses the refresh, or back button or changes the URL, and many more than one alert box appears. But I can not use the <prompt /> tag in my project because it is not available in "react-router-dom": "^6.3.0".
This alternative approach to do that, useeffect and browser back button method to do apply your prompt code.