# Lifecycle Methods

Vue Lifecycle Methods are methods which are called before events. There are 9 events that calls lifecycle methods.&#x20;

* onBeforeMount
* onMounted
* onBeforeUpdate
* onUpdated
* onBeforeUnmount
* onUnmounted
* onActivated
* onDeactivated
* onErrorCaptured

With vucript, you can write lifecycle functions like normal function.

```typescript
const lifecycleFunctionName = () => {
    //some actions here
};
```

### Example

```typescript
import { reactive } from 'Vucript'
const counter:reactive<number> = 0;
const onMounted = ()=>{
    add();
    console.log('mounted!');
}
function add(){
    counter++;
}
```

This code is compiled to

```typescript
import { defineComponent, ref, onMounted } from "vue";
export default defineComponent({
  setup() {
    const counter = ref<number>(0);
    const add = function () {
      counter.value++;
    };
    onMounted(() => {
      add();
      console.log("mounted!");
    });
    return { counter, add };
  },
});
```

