0

I have a panel that opens like a modal from right to left. Inside the panel I have a left navigation with different options that when clicking render different components.

These components are forms and I wanna prompt the user if he navigates away from a component while having unsaved changes.

I cannot use react routes since I have no routes for these, theyre just components.

Is there a way so that I cant prevent the user from navigating away or from unmounting the component and display that popup?

Muhamed Krasniqi
  • 1,134
  • 1
  • 13
  • 20

1 Answers1

-2

If it is an input you can use onBlur

or onMouseLeave if the mouse leave the component

  • I dont understand what ur saying, onblur or onmousleave serve no purpose here. Read the question once more – Muhamed Krasniqi Apr 15 '22 at 02:16
  • @MuhamedKrasniqi what i am implying is that you can use both event handlers above to fire and function and just say use an alert() to display the massage you want to – Efraim Jerszurki Apr 15 '22 at 11:26