N
N
Ninja Mate2016-05-23 07:53:35
JavaScript
Ninja Mate, 2016-05-23 07:53:35

How to use componentWillUnmount to pop up a confirmation box?

For some elements, I want to make a confirmation popup when the user wants to leave it.
componentWillUnmount is perfect, but how do you undo and commit?
The idea is to display a modal with information and ask Yes / No there. If Yes, continue, if No, then cancel the transition. Tell me how.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2016-05-23
@victorzadorozhnyy

No way. This method is created for cleanup in the component ( source ).
Use native browser methods for this.
// EDIT
If your component changes due to some event, it is logical that you need to warn the user in this handler, based on your conditions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question