DEV Community

Subhasish Sarkar
Subhasish Sarkar

Posted on

window.confirm component in react

In web app we frequently use window.confirm() which return a promise and when resolved we do something base on the user input. I tried doing the same thing with context api. The context provider redender the children and a confirmation modal componet. The context gives an useConfirm() method which returns an async function lets say confirm(). Now calling this confirm() method with an await, the confirmation modal gets rendered.

I have created a npm library of this implementation and also added some customisation feature.

Check this link for full details: https://www.npmjs.com/package/react-confirm-window

Latest comments (0)