# State Hook

It is how useState hook would look in Angular.

## 📌 State Hook in Template

An example in `COMPONENT.template.html`.

```markup
<div *useState="let x default 0">
  <button (click)="x = x + 1">Press me: {{x}} 🔥</button>
</div>
```

## 📌 State Hook with Ivy

An example in `COMPONENT.component.ts`.

```typescript
const initialValue = 0;

@Component({
  selector: 'app-use-state',
  template: `
    <button (click)="setCount(count + 1)">
      Press me: {{count}} 🔥
    </button>
  `
})
@UseState(['count', 'setCount'], initialValue)
class Host {}
```

![](https://3405684832-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LO9nIadpngrjQA2qBpG%2F-LTCyyue4GuTAcZgC1zE%2F-LTD2_FyYDXeOYSHlSLN%2FScreenshot%202018-12-08%20at%2016.42.18.png?alt=media\&token=3b134057-2e06-4eb1-9dfd-c9f30ebc31b1)

