-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support promises for callbacks like onDelete #117
Comments
Yes, this is a good point. A confirmation modal is a pretty typical use case, so would be good to handle this. I think the best way would be to make the actual internal Thanks for the suggestion. |
@yaswanthmaddula-sureify the Update functions do currently support async methods, so if you can get your confirmation to be onDelete={
async () => {
const response = await getUserConfirmation("Are you sure?")
if (respose !== "CONFIRM") return false
}
} I know that doesn't work that well with most React libraries which don't return a Promise from a confirmation dialog, however here is a way of doing it that should work, though I haven't tried it myself: https://daveteu.medium.com/react-custom-confirmation-box-458cceba3f7b |
Okay, I think that will work then. Thanks. |
Let me know if you get it working. If it's too fiddly to implement, I might still look at improving this. |
@yaswanthmaddula-sureify -- here's another library that allows you to await a confirmation: https://github.com/palerdot/use-async-confirm Looks quite useful, thought haven't personally tried it yet. |
Discussed in #116
Originally posted by yaswanthmaddula-sureify September 5, 2024
I would like to have confirmation modal, if user tries to delete certain important keys in the json. As the
onDelete
callback is synchronous as of now, the only way for me to achieve this is using window.confirm(). It would be useful if there is a way like promises to support such usecases.The text was updated successfully, but these errors were encountered: