Skip to content

frontend-web-editor


Function: UseLayout()

UseLayout(enabled): void

Defined in: app/hooks/faultTree/useLayout.ts:55

Hook for applying a hierarchical tree layout to nodes in a React Flow diagram.

This hook utilizes the D3 library for tree layout and React Flow for managing nodes and edges in a flowchart-like UI It triggers a layout re-calculation whenever the number of nodes changes and animates the nodes to their new positions.

Parameters

enabled

boolean = true

When false, disables layout computation and animation; defaults to true.

Returns

void

Remarks

This hook is designed to work with D3's tree layout and is used for hierarchical tree-like structures. It also includes animation logic to smoothly transition nodes to their new positions. The hook ensures horizontal layout of the nodes