Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IComponent<TProps, TChildren>

Interface that must be implemented by all components.

Type parameters

  • TProps

    Type defining properties that can be passed to this class-based component. Default type is an empty object (no properties).

  • TChildren

    Type defining components, elements or other objects that can be used as children for this class-based component. Default is any.

Hierarchy

Implemented by

Index

Properties

Optional Readonly displayName

displayName: string

Components can define display name for tracing purposes; if they don't the default name used is the component's class constructor name. Note that this method can be called before the virtual node is attached to the component.

Optional props

props: CompProps<TProps, TChildren>

Component properties passed to the constructor. For managed components, the properties are updated when the component's parent is updated.

Optional vn

Sets, gets or clears the virtual node object of the component. This property is set twice:

  1. Before the component is rendered for the first time: the component must remember the passed object.
  2. Before the component is destroyed: null is passed as a parameter and the component must release the remembered object.

Methods

Optional afterUpdate

  • afterUpdate(): void
  • Optional method that is called after all components that are scheduled to be updated in a Mimbl tick, are updated. If implemented, this method will be called every time the component is scheduled to be updated. This method is called after all modifications to DOM resulting from updaing components have been already done.

    Returns void

Optional beforeUpdate

  • beforeUpdate(): void
  • Optional method that is called before any components that are scheduled to be updated in a Mimbl tick, are updated. If implemented, this method will be called every time the component is scheduled to be updated. This method can read DOM layout information (e.g. element measurements) without the risk of causing forced layouts.

    Returns void

Optional didMount

  • didMount(): void
  • Notifies the component that it was successfully mounted. This method is called after the component is rendered for the first time and the content of all its sub-nodes is added to the DOM tree.

    Returns void

Optional didReplace

  • didReplace(oldComp: IComponent<TProps, TChildren>): void
  • Notifies the component that it replaced the given old component. This allows the new component to copy whatever internal state it needs from the old component.

    Parameters

    Returns void

Optional getUpdateStrategy

  • Retrieves update strategy object that determines different aspects of component behavior during updates.

    Returns UpdateStrategy

Optional handleError

  • handleError(err: any): void
  • Handles an exception that occurred during the rendering of one of the component's children. If this method is not implemented or if it throws an error, the error will be propagated up the chain of components until it reaches a component that handles it. If none of the components can handle the error, the entire tree will be unmounted.

    Parameters

    • err: any

      An exception that was thrown during the component's own rendering or rendering of one of its descendants.

    Returns void

render

  • render(): any
  • Returns the component's content that will be ultimately placed into the DOM tree.

    Returns any

Optional shouldUpdate

  • shouldUpdate(newProps: CompProps<TProps, TChildren>): boolean
  • This method is only used by managed components.

    Informs the component that new properties have been specified. At the time of the call this.props refers to the "old" properties. If the component returns true, then its render method will be called. At that time,the original props object that was passed into the component's constructor will have these new properties. If the component doesn't implement the shouldUpdate method it is as though true is returned. If the component returns false, the render method is not called and the DOM tree of the component remains unchanged. The properties of the component, however, still change.

    Parameters

    • newProps: CompProps<TProps, TChildren>

      The new properties that the parent component provides to this component.

    Returns boolean

    True if the component should have its render method called and false otherwise.

Optional willMount

  • willMount(): void
  • Notifies that the component is about to render its content for the first time. This method is called when the virtual node has already been set so the component can request services from it.

    Returns void

Optional willUnmount

  • willUnmount(): void
  • Notifies that the component's content is going to be removed from the DOM tree. After this method returns the component is destroyed.

    Returns void

Generated using TypeDoc