Skip to content

API Reference / @gtkx/react / config / ElementBehavior

Type Alias: ElementBehavior<T>

ElementBehavior<T> = object

Defined in: reconciler/registry.d.ts:36

Customizes how one element type places children and applies props. Hooks other than create receive the GObject instance; update and flush also take the private per-node context initialize built, and attach, reorder and detach read it off their info object. Subtypes inherit a type's behaviors, except for create, which is consulted only for the type it is registered on.

Type Parameters

T

T extends GObject.Object = GObject.Object

Properties

attach?

optional attach?: (object, child, info) => unknown

Defined in: reconciler/registry.d.ts:42

Places a child, claiming it by returning anything other than undefined.

Parameters

object

T

child

GObject.Object

info

PlaceInfo

Returns

unknown


constructOnly?

optional constructOnly?: string[]

Defined in: reconciler/registry.d.ts:60

Props the behavior can only apply while the element is being built, because the library exposes no counterpart to whatever applied them. Changing one after it has been applied throws instead of silently applying the new value on top of the old.


create?

optional create?: (props) => GObject.Object

Defined in: reconciler/registry.d.ts:38

Builds the GObject from its construct props, for types whose constructor does more than set properties.

Parameters

props

Props

Returns

GObject.Object


deferred?

optional deferred?: string[]

Defined in: reconciler/registry.d.ts:54

Props to withhold from the constructor, leaving them for a later hook to apply.


detach?

optional detach?: (object, child, info) => void

Defined in: reconciler/registry.d.ts:46

Removes a child this behavior attached.

Parameters

object

T

child

GObject.Object

info

DetachInfo

Returns

void


flush?

optional flush?: (object, context) => void

Defined in: reconciler/registry.d.ts:52

Runs after the commit that touched the node, once every child has been placed.

Parameters

object

T

context

unknown

Returns

void


initialize?

optional initialize?: (object) => unknown

Defined in: reconciler/registry.d.ts:40

Builds the private per-node context the other hooks receive, once per node.

Parameters

object

T

Returns

unknown


reorder?

optional reorder?: (object, child, info) => unknown

Defined in: reconciler/registry.d.ts:44

Moves an already-attached child; without it, the whole slot is detached and re-attached in order.

Parameters

object

T

child

GObject.Object

info

PlaceInfo

Returns

unknown


resolve?

optional resolve?: (object, child) => GObject.Object | null

Defined in: reconciler/registry.d.ts:48

Returns the object the container adopts for a child, overriding whatever attach returned.

Parameters

object

T

child

GObject.Object

Returns

GObject.Object | null


update?

optional update?: (object, prev, next, context) => Iterable<string> | undefined

Defined in: reconciler/registry.d.ts:50

Applies changed props and returns the names it consumed, which are then not set as GObject properties.

Parameters

object

T

prev

Props

next

Props

context

unknown

Returns

Iterable<string> | undefined

Released under the MPL-2.0 License.