Skip to main content

Base

Used by base renderer to build the node tree

BaseAttributesSchema

The base attributes are resolved in following sequence from the table below. All values could be actual value or resolvable function. The function will take current node as first parameter.

NameTypeDescription
_tags

[ string ]

Names of the shape's React component. It will be used to construct other attributes if those are not provided explicitly.

_type

string

Type of the component. Default to first of the tags value if not provided. Primarily used for Infrastructure as Code IaC

_title

string

Displayed title of the shape

_name

string

Name of the shape for identification. IaC

_version

string

Version of the shape if applicable. Parent version are passed down to children automatically. IaC

_id

string

An unique identifier for the component. IaC

Base Attributes Example

Given example below,

tags.tsx
import { Shape } from "@dinghy/base-components";

const TagLevel1 = (props: any) => <Shape {...props} />;
const TagLevel2 = (props: any) => <TagLevel1 {...props} />;

export default function App() {
return (
<Shape _title="Tags example">
<TagLevel2 />
</Shape>
);
}

The TagLevel2 component has

  1. _tags = [TagLevel2, TagLevel1, Shape]
  2. _type = tag_level2
  3. _title = Tag Level2
  4. _name = tag-level2
  5. _id = taglevel2

Fallback Resolution

_title, _name, and _id will fallback to their respective title, name, and id attributes if they are not provided explicitly.

The same resolution logic applies reversely as well e.g. name will fallback to _name if not provided explicitly.

LifecycleSchema

Events been invoked during lifecycle of the node

NameTypeDescription
_afterDataBind

function(node)

Invoked after all attributes resolved to the node tree

_beforeGenerate

function(node)

Invoked before the node is generated to target format