# useAlert

The react hook for creating alerts and confirm alerts

## Installation

```tsx
import { useAlert } from 'uxp/components';
```

## Signature

```tsx
function useAlert(): IAlertResult
```

## Examples

```tsx
alerts.show("Item updated")
```

```tsx
alerts.show({title: "Info", content: "Item updated", cancelButtonTitle: "Ok" })
```

```tsx
Auto close an alert (disabled by default)

alerts.show({content: 'Item updated', autoClose: true, closeAfter: 2000})
```

```tsx
wait until alert is closed

 await alerts.show("Item updated")
 ... execute the rest
```

```tsx
let hasConfirmed = await alerts.confirm("Are you sure?")

 if(hasConfimed) {
     ... execute the rest
 }
```

```tsx
alerts.confirm("Are you sure?")
.then(hasConfirmed => {
     if(hasConfirmed) {
         ... execute the rest
     }
})
```

## Related Types

* [IAlertResult](https://help.iviva.com/uxp/v5/additional-resources/types/ialertresult)
* [IBaseAlertProps](https://help.iviva.com/uxp/v5/additional-resources/types/ibasealertprops)
* [IAlertContent](https://help.iviva.com/uxp/v5/additional-resources/types/ialertcontent)
* [IConfirmAlertProps](https://help.iviva.com/uxp/v5/additional-resources/types/iconfirmalertprops)
* [IFormAlertProps](https://help.iviva.com/uxp/v5/additional-resources/types/iformalertprops)
* [IAlertFormField](https://help.iviva.com/uxp/v5/additional-resources/types/ialertformfield)
* [DynamicFormFieldProps](https://help.iviva.com/uxp/v5/additional-resources/types/dynamicformfieldprops)
* [FormValue](https://help.iviva.com/uxp/v5/additional-resources/types/formvalue)
* [IFormData](https://help.iviva.com/uxp/v5/additional-resources/types/iformdata)
* [CustomValidateResponse](https://help.iviva.com/uxp/v5/additional-resources/types/customvalidateresponse)
* [FormSectionProps](https://help.iviva.com/uxp/v5/additional-resources/types/formsectionprops)
