Justin Sorensen

React Alert Dialog

April 28, 2020

Uses:

React hooks + context + Promise to provide a reusable dialog.

Example:

const YourAwesomeComponent = () => {
  const confirm = useConfirmation()

  confirm({
    variant: "danger",
    title: "Are you sure you want to remove this burrito?",
    description: "If you will remove this burrito you will regret it 😡!!"
  }).then(() => {
    api.deleteThisAwfulBurrito();
  });
}

Source:

https://dev.to/dmtrkovalenko/the-neatest-way-to-handle-alert-dialogs-in-react-1aoe


I'm a web developer at dystrick, who lives and works in the Silicon Valley. I'm passionate about cutting edge web tech, great design and UX, and performance. When I'm not working you can find me in the Sierra Nevada mountains... camping, fishing, and off-roading with my family and friends.

You can contact me by email hey@sorensenjg.com
or follow me at GitHub

© 2020 sorensenjg. All Rights Reserved.