# useTimeout
> A declarative wrapper around setTimeout that manages cleanup automatically.

A declarative wrapper around `setTimeout` that automatically handles cleanup on unmount or delay changes. Pass `null` as the delay to disable the timeout.

## Import

```js
import { useTimeout } from '@volue/wave-react';
```

## Example

```jsx
() => {
  const [visible, setVisible] = React.useState(false);

  useTimeout(
    () => {
      setVisible(true);
    },
    visible ? null : 2000
  );

  return (
    <Flex flow="column" cross="start">
      <Text>{visible ? 'Message appeared after 2 seconds!' : 'Waiting…'}</Text>
      {visible && (
        <Button
          onClick={() => {
            setVisible(false);
          }}
        >
          {'Reset'}
        </Button>
      )}
    </Flex>
  );
};
```

---

## API reference

### Arguments

| Name       | Type                       | Default | Description                                              | Required |
| ---------- | -------------------------- | ------- | -------------------------------------------------------- | -------- |
| `callback` | `(...args: any[]) => void` | `—`     | The function to call after the delay.                    | Yes      |
| `delay`    | `number \| null`           | `—`     | Delay in milliseconds. Pass null to disable the timeout. | Yes      |

### Returns

`void`
