Skip to content

Component lifecycle

Filatov Dmitry edited this page Aug 12, 2015 · 32 revisions

onInit

void onInit()

The callback which will be invoked after a component has been created. It's a good place to create initial state for the stateful components.

onRender

VNode onRender(
    Object attrs,
    Array children
)

The callback which will be invoked when a component should be rendered. It's an essential part of the component lifecycle. It should return a single child node based on attrs, children and possible internal state of a component. This child node can be either a TagNode or another ComponentNode with a component that you've defined. This method is supposed to be pure, it should have no side effects. It's allowed to return null value, in this case <noscript/> tag will be rendered.

onMount

void onMount(
    Object attrs
)

The callback which will be invoked after a component has been mounted to the DOM.

onAttrsReceive

void onAttrsReceive(
    Object newAttrs,
    Object prevAttrs
)

onUpdate

void onUpdate(
    Object attrs
)

The callback which will be invoked after a component has updated its DOM.

onUnmount

void onUnmount()

The callback which will be invoked before a component is unmounted from the DOM.