|
|
|
|
|
by pietschy
1966 days ago
|
|
React examples like this always strike me as a great reason to avoid react, but then I'm an old OO dinosaur I suspect. In our framework (that has angular underneath) we go.. interactionContext.startActivity(MyConfirmDialog).then(result => ...);
...and the interactionContext handles back button clicks and makes sure the dialog is cancelled and our history is kept clean.It even works with nested interactions (i.e. the dialog can start a new interaction in place). Again, the user can click the back button repeatedly to back out of the interaction and everything just works. I've got no idea how you'd do that in React. edit - fixed typos |
|
It's simple, you can place a component that provides dialogs near the root of your component tree and provide async functions which open such dialogs to the descendant components (e.g. via contexts). These functions can then be made to resolve only when the dialogs are closed. Thus, all descendant components can use dialogs in the same manner as shown in your example.