-
Notifications
You must be signed in to change notification settings - Fork 16
Component lifecycle
Component's lifecycle is represented via various hooks called by Vidom at specific points.
static Object getDefaultAttrs()
The callback will be invoked once after a first instance of a component has been created.
Object onInitialStateRequest(
Object attrs
)
The callback will be invoked once while a component instance is being created. The result will be stored as an initial state.
void onInit(
Object attrs
)
The callback will be invoked once after a component instance has been created and an initial state has been calculated.
VNode onRender(
Object attrs,
Array children
)
The callback 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.
void onMount(
Object attrs
)
The callback will be invoked once after a component has been mounted to the DOM.
void onAttrsReceive(
Object newAttrs,
Object prevAttrs,
Array<VNode> | null newChildren,
Array<VNode> | null oldChildren
)
The callback will be invoked each time when a component is receiving new attributes.
Boolean shouldUpdate(
Object newAttrs,
Object prevAttrs,
Array<VNode> | null newChildren,
Array<VNode> | null oldChildren
)
The callback will be invoked each time before a component is going to perform update.
If it returns false
a component won't be updated and rerendered.
void onUpdate(
Object newAttrs,
Object prevAttrs,
Array<VNode> | null newChildren,
Array<VNode> | null oldChildren
)
The callback will be invoked each time after a component has updated its DOM.
Object onChildContextRequest(
Object attrs
)
The callback will be invoked each time before a component is going to pass its context to children.
void onUnmount()
The callback will be invoked once before a component is unmounted from the DOM.