Skip to main content

appendChild

Adds a new child to the end of the children array. That is, visually on top of all other children.

Signature

appendChild(child: SceneNode): void

Remarks

Reparenting nodes is subject to many restrictions. For example, some nodes cannot be moved, others would break the document if moved. Below are possible exceptions that can be thrown if the operation is invalid.

If this is called on an auto-layout frame, calling this function can cause this layer to be resized and children to be moved.

Possible error cases

Cannot move node. Node is the scene root, which cannot be reparented

Cannot move node. Doing so would create a parenting cycle

Cannot move node. The root node cannot have children of type other than PAGE

Cannot move node. Nodes other than the root node cannot have children of type PAGE

Cannot move node. New parent is of a type that cannot have children

Cannot move node. New parent is a internal, readonly-only node

Cannot move node. Node is an internal, readonly-only node

Cannot move node. New parent is an instance or is inside of an instance

Cannot move node. Node is inside of an instance

Cannot move node. Reparenting would create a component cycle

Cannot move node. Reparenting would create a component inside a component

Cannot move node. Reparenting would create a component set cycle

Cannot move node. A COMPONENT_SET node cannot have children of type other than COMPONENT