Hooks

Each component instance goes through a series of steps, we can execute functions called hooks in each of these steps:

import { _ } from "bemtv";

const { onInit, onMount, onUpdate, onUnmount } = _`App`();

onInit(() => {
  // Called(only once) when the instance is initialized.
});

onMount(() => {
  // Called(only once) after the component template has been mounted in the DOM.
});

onUpdate(() => {
  // Called after the template update is applied to the DOM.
});

onUnmount(() => {
  // Called(only once) after the component is removed/unmounted from the template it was in.
});

Last updated