Skip to content

react

Interfaces

Props

Defined in: react/types.ts:179

Generic dictionary representing a component props object. Pre-defines common React properties (key, ref, style, styles, children) while allowing arbitrary custom properties via index signature.

Indexable

[key: string]: any

Properties

PropertyTypeDefined in
key?Keyreact/types.ts:180
ref?Ref<any>react/types.ts:181
style?stringreact/types.ts:182
styles?Record<string, any>react/types.ts:183
children?ReactNodereact/types.ts:184

ReactElement

Defined in: react/types.ts:212

Ephemeral virtual DOM descriptor (snapshot blueprint) created by createElement or <Component />. Holds props and child elements for the current render pass, then is discarded by the garbage collector.

Type Parameters

Type ParameterDefault type
P extends PropsProps
T extends ElementType<any>ElementType<any>

Properties

PropertyTypeDescriptionDefined in
key?KeyOptional key for list reconciliation stability.react/types.ts:214
typeTElement type: native Factorio string tag or functional component.react/types.ts:216
propsP & objectElement props including children.react/types.ts:218

EntityLifecycleCallbacks

Defined in: react/types.ts:231

Lifecycle event handlers for components linked to a specific Factorio in-game entity (useEntityLifecycle). Automatically handles cases where the bound entity is mined, destroyed, or revived.

Properties

PropertyTypeDescriptionDefined in
onDestroyed?(this: void) => voidCalled when the bound entity is destroyed, mined, or becomes invalid in the game world.react/types.ts:233
onRevived?(this: void, newEntity: LuaEntity) => voidCalled when the bound entity is revived (e.g. via undo / ghost revival), providing the fresh LuaEntity reference.react/types.ts:235

Fiber

Defined in: react/types.ts:249

Fiber - Serializable state node in our component tree. Persisted directly into Factorio global storage (storage.reactRoots). Contains ONLY safe-to-serialize plain data (no functions, no metatables, no C++ references).

Properties

PropertyTypeDescriptionDefined in
idnumberUnique sequential ID assigned to this fiber node.react/types.ts:251
typestringString identifier of the component or native tag name.react/types.ts:253
key?KeyOptional reconciliation key.react/types.ts:255
hooksunknown[]Serialized hook state slots (primitive state, reducer state).react/types.ts:257
childrenFiber[]Child fiber nodes.react/types.ts:259

TransientState

Defined in: react/types.ts:285

Properties

PropertyTypeDescriptionDefined in
fiber?FiberDirect in-memory reference to the corresponding serializable Fiber node.react/types.ts:287
parent?FiberDirect in-memory reference to the parent Fiber node in the component tree.react/types.ts:289
root?ReactRootDataDirect in-memory reference to the enclosing React root data.react/types.ts:291
propsPropsLatest props snapshot passed to this fiber.react/types.ts:293
elem?LuaGuiElementLive C++ Factorio GUI element reference.react/types.ts:295
hooks?Record<number, HookInstance>Array of in-memory hook instances keyed by hook slot index (0..N).react/types.ts:297
handlers?Record<Color<any>, | ((this: void, event: GuiEventData) => void) | undefined>Fast pre-indexed event handlers table keyed directly by Factorio event ID (O(1) lookup).react/types.ts:299
elementType?anyLive component function or native tag element type reference in RAM.react/types.ts:301

ReactRootData

Defined in: react/types.ts:307

Root metadata saved in global storage.reactRoots to enable rehydration upon game load.

Properties

PropertyTypeDescriptionDefined in
idnumberUnique sequential Root ID.react/types.ts:309
containerElemLuaGuiElementNative parent container element (e.g. player.gui.screen).react/types.ts:311
fiber?FiberRoot fiber tree.react/types.ts:313
rootTypestringRegistered string name of the root component function.react/types.ts:315
rootProps?PropsInitial props passed to the root component.react/types.ts:317

UseWindowOptions

Defined in: react/types.ts:325

Configuration options for the useWindow lifecycle hook.

Properties

PropertyTypeDescriptionDefined in
autoCenter?booleanAutomatically centers the window upon opening and disables position persistence. Default: false.react/types.ts:327
pinnable?booleanEnables pinning functionality (window stays open when ‘E’/Escape is pressed). Default: false.react/types.ts:329
defaultPinned?booleanInitial pinned state if no saved state is found in storage. Default: false.react/types.ts:331
windowKey?stringCustom unique storage key for saving coordinates and pin state. Default: fiber.type.react/types.ts:333
closeOnEscape?booleanAutomatically closes window on Escape/‘E’ when not pinned. Default: true.react/types.ts:335
guiTypeFilter?gui_typeFilter for on_gui_closed event type. Default: defines.gui_type.custom.react/types.ts:337
locationDebounceTicks?numberDelay in game ticks before saving dragged window position to storage. Default: 30 (0.5s).react/types.ts:339

UseWindowReturn

Defined in: react/types.ts:345

Controller interface returned by the useWindow hook.

Properties

PropertyTypeDescriptionDefined in
close(this: void) => voidProgrammatically closes and unmounts the window, resetting player.opened and destroying the root.react/types.ts:347
pinnedbooleanCurrent pinned state of the window.react/types.ts:349
setPinnedDispatch<SetStateAction<boolean>>State setter for pinned. Automatically persists changes to storage.reactWindowPinned.react/types.ts:351
togglePin(this: void) => voidHelper that toggles the pinned state (setPinned(prev => !prev)).react/types.ts:353
onLocationChanged?(this: void, ev: OnGuiLocationChangedEvent) => voidEvent handler to pass to onLocationChanged prop to save window coordinates on drag.react/types.ts:355

ObserverData

Defined in: react/types.ts:367

Internal tracking record for an entity lifecycle observer (useEntityLifecycle).

Properties

PropertyTypeDescriptionDefined in
entityLuaEntityLive Factorio entity reference.react/types.ts:369
unit_number?UnitNumberEntity unit number if supported.react/types.ts:371
surface_indexSurfaceIndexSurface index where the entity was placed.react/types.ts:373
positionMapPositionMap coordinates of the entity.react/types.ts:375
callbacksEntityLifecycleCallbacksLifecycle callbacks to trigger on death/mining/revival.react/types.ts:377

PendingEffect

Defined in: react/types.ts:383

Internal descriptor for a deferred side-effect queued during component render.

Properties

PropertyTypeDescriptionDefined in
fiberIdnumberUnique ID of the component Fiber node.react/types.ts:385
hookIndexnumberSequential hook slot index within the component.react/types.ts:387
effectEffectCallbackSide-effect callback to execute in the commit phase.react/types.ts:389

DebounceState

Defined in: react/types.ts:395

Internal state tracking an active debounced task in the scheduler.

Properties

PropertyTypeDescriptionDefined in
taskId?numberScheduler task ID if a timeout is currently pending.react/types.ts:397
targetTick?numberTarget game tick when callback should be executed.react/types.ts:399
callback(this: void, …args: any[]) => voidCurrent callback closure to execute upon timer expiry.react/types.ts:401

Type Aliases

GuiElementFor

type GuiElementFor<T> = Extract<Color, {
type: T;
}>;

Defined in: react/types.ts:46

Automatically extracts the concrete live LuaGuiElement subtype for element type T. Example: GuiElementFor<"button"> resolves to ButtonGuiElement.

Type Parameters

Type ParameterDefault type
T extends ColorColor

Ref

type Ref<T> = RefObject<T> | RefCallback<T>;

Defined in: react/types.ts:55

Universal ref type: either a mutable { current } object container or a callback function.

Type Parameters

Type ParameterDefault type
TColor

NonFunction

type NonFunction<T> = T extends (this: void, ...args: any[]) => any ? never : T;

Defined in: react/types.ts:61

Utility type restricting state values to serializable non-functional types. Functions cannot be saved in persistent Factorio storage and should be managed via useCallback or useRef.

Type Parameters

Type Parameter
T

SetStateAction

type SetStateAction<T> = T | ((this: void, prev: T) => T);

Defined in: react/types.ts:64

A value or a functional state updater callback.

Type Parameters

Type Parameter
T

Dispatch

type Dispatch<A> = (this: void, value: A) => void;

Defined in: react/types.ts:67

A function that updates state (e.g. from useState or useReducer).

Type Parameters

Type Parameter
A

Parameters

ParameterType
thisvoid
valueA

Returns

void


EffectCleanup

type EffectCleanup = (this: void) => void;

Defined in: react/types.ts:70

An optional cleanup callback returned by a side-effect.

Parameters

ParameterType
thisvoid

Returns

void


EffectCallback

type EffectCallback = (this: void) => void | EffectCleanup;

Defined in: react/types.ts:73

A side-effect callback function passed to useEffect.

Parameters

ParameterType
thisvoid

Returns

void | EffectCleanup


DependencyList

type DependencyList = readonly unknown[];

Defined in: react/types.ts:76

A list of dependencies passed to hooks (e.g. useEffect, useMemo, useCallback).


EventMapping

type EventMapping = object;

Defined in: react/types.ts:85

Single source of truth: React handler prop name -> Native Factorio event payload structure.

Properties

PropertyTypeDefined in
onClickColorreact/types.ts:86
onClosedColorreact/types.ts:87
onConfirmedColorreact/types.ts:88
onTextChangedColorreact/types.ts:89
onCheckedStateChangedColorreact/types.ts:90
onElemChangedColorreact/types.ts:91
onValueChangedColorreact/types.ts:92
onSelectionStateChangedColorreact/types.ts:93
onSwitchStateChangedColorreact/types.ts:94
onSelectedTabChangedColorreact/types.ts:95
onHoverColorreact/types.ts:96
onLeaveColorreact/types.ts:97
onLocationChangedColorreact/types.ts:98
onOpenedColorreact/types.ts:99

GuiEventData

type GuiEventData = EventMapping[keyof EventMapping];

Defined in: react/types.ts:103

Union of all possible native Factorio GUI event payloads.


GuiEventHandler

type GuiEventHandler<K, T> = (this: void, event: TypedEvent<EventMapping[K], T>) => void;

Defined in: react/types.ts:115

Generic strongly-typed handler for native Factorio GUI events.

Type Parameters

Type ParameterDefault type
K extends keyof EventMapping-
T extends ColorColor

Parameters

ParameterType
thisvoid
eventTypedEvent<EventMapping[K], T>

Returns

void


Key

type Key = string | number;

Defined in: react/types.ts:191

Unique identifier used by the reconciler to match and preserve fiber state across renders.


ReactNode

type ReactNode =
| ReactElement<any>
| boolean
| undefined
| ReactNode[];

Defined in: react/types.ts:199

Anything that can be rendered as JSX children:

  • A virtual element (<Button />, <Frame />)
  • Primitives for conditional rendering (boolean, undefined)
  • An array of child nodes

ElementType

type ElementType<P> =
| Color
| ComponentType<P>;

Defined in: react/types.ts:206

Valid element constructor or tag identifier:

  • Native Factorio primitive tag name ("button" | "textfield" | "flow" | ...)
  • Custom functional component (ComponentType<P>)

Type Parameters

Type ParameterDefault type
P extends PropsProps

ComponentType

type ComponentType<P> = (this: void, props: P) => ReactNode;

Defined in: react/types.ts:225

Functional component blueprint: a pure or stateful function that accepts props and returns a ReactNode. Represents the component definition itself (the factory/recipe), as opposed to an instantiated <ReactElement />.

Type Parameters

Type ParameterDefault type
P extends PropsProps

Parameters

ParameterType
thisvoid
propsP

Returns

ReactNode


FiberId

type FiberId = number;

Defined in: react/types.ts:239

Unique numeric identifier for a virtual Fiber node.


RootId

type RootId = number;

Defined in: react/types.ts:242

Unique numeric identifier for a mounted React root tree.


EntityDestroyedEvent

type EntityDestroyedEvent =
| Color
| Color
| Color
| Color
| Color;

Defined in: react/types.ts:359

Union of all Factorio event payloads that signal entity destruction or mining.


EntityBuiltEvent

type EntityBuiltEvent =
| Color
| Color
| Color
| Color
| Color;

Defined in: react/types.ts:362

Union of all Factorio event payloads that signal entity placement, ghost construction, or revival.


PrimitiveProps

type PrimitiveProps<T> = NativePropsFor<T> & ReactInternalProps<T> & EventHandlersFor<T>;

Defined in: react/types.ts:430

Combined props for a native Factorio element T:

  1. Native Factorio element properties (NativePropsFor)
  2. React internal props (children, styles, style, ref)
  3. Strictly typed event handlers (EventHandlersFor)

Type Parameters

Type ParameterDefault type
T extends ColorColor

Variables

componentRegistry

const componentRegistry: Record<string,
| ComponentType<any>
| undefined> = {};

Defined in: react/index.ts:183

In-memory registry of root component functions keyed by unique string names.

Factorio cannot serialize Lua closures/functions into storage. During game save, root descriptors store string component identifiers (rootType). On game load (on_load), the engine looks up the component function in this registry to rehydrate the virtual DOM tree and reattach event handlers.


transientStates

const transientStates: Record<FiberId,
| TransientState
| undefined> = {};

Defined in: react/index.ts:240

In-memory transient state map for all active Fiber nodes. Stores non-serializable objects (C++ LuaGuiElement references, closures, cleanups, memo cache). This RAM-only table is never written to disk and is safely reconstructed during hydration.

Functions

createElement()

function createElement<P>(
type: any,
props?: P, ...
children: ReactNode[]): ReactElement<P>;

Defined in: react/index.ts:104

Creates a virtual React element descriptor.

Type Parameters

Type ParameterDefault type
P extends PropsProps

Parameters

ParameterTypeDescription
typeanyComponent function or primitive Factorio tag name (e.g. “flow”, “button”)
props?PElement props object
children?ReactNode[]Child elements

Returns

ReactElement<P>

A virtual ReactElement object


Fragment()

function Fragment(props: object): ReactNode;

Defined in: react/index.ts:129

Fragment component to group multiple JSX elements without a wrapper DOM node.

Parameters

ParameterType
props{ children?: ReactNode; }
props.children?ReactNode

Returns

ReactNode


registerComponent()

function registerComponent<T>(name: string, component: T): T;

Defined in: react/index.ts:195

Registers a root component function under a unique string name. Must be called at top-level module load time so that on_load can find it.

Type Parameters

Type Parameter
T extends ComponentType<any>

Parameters

ParameterTypeDescription
namestringUnique component identifier (e.g. “my-mod-main-gui”)
componentTThe functional component

Returns

T

The passed component function


getComponentTypeName()

function getComponentTypeName(elementType: any): string;

Defined in: react/index.ts:213

Resolves a human-readable registry name for a component or native tag name. Uses a zero-cost O(1) LuaTable lookup for functional components.

Parameters

ParameterTypeDescription
elementTypeanyComponent function or native tag name

Returns

string

Resolved string name


getComponentType()

function getComponentType(elementType: any): any;

Defined in: react/index.ts:228

Resolves an ElementType from a registered name or passes through the component function / native tag.

Parameters

ParameterTypeDescription
elementTypeanyComponent function, native tag name, or registered component string identifier

Returns

any

Resolved ComponentType or native tag string


fiberTrace()

function fiberTrace(fiber: Fiber): string;

Defined in: react/index.ts:248

Formats a Fiber node and its hierarchy context into a compact string for structured logging.

Parameters

ParameterTypeDescription
fiberFiberTarget Fiber node

Returns

string

Formatted debug string, e.g. #14<SlotButton key=slot-3 parent=#10<SectionGroup> root=#1>


createFiber()

function createFiber(type: string, key?: Key): Fiber;

Defined in: react/index.ts:270

Allocates a new serializable Fiber node and initializes its RAM transient state.

Parameters

ParameterTypeDescription
typestringComponent name or native tag name
key?KeyOptional reconciliation key

Returns

Fiber

The newly allocated Fiber node


getTransient()

function getTransient(id: number): TransientState;

Defined in: react/index.ts:293

Retrieves or initializes the in-memory RAM TransientState for a given Fiber ID.

Parameters

ParameterTypeDescription
idnumberUnique numeric Fiber ID

Returns

TransientState

The TransientState record


getHook()

function getHook(fiberId: number, idx: number): HookInstance;

Defined in: react/index.ts:309

Retrieves or lazily creates an in-memory HookInstance for the given Fiber ID and hook slot.

Parameters

ParameterTypeDescription
fiberIdnumberUnique Fiber node ID
idxnumberZero-based hook slot index

Returns

HookInstance

The HookInstance container


assignRef()

function assignRef(ref: Ref, value: any): void;

Defined in: react/index.ts:331

Assigns a native Factorio LuaGuiElement reference to a React ref. Supports both function callbacks ((elem) => ...) and mutable ref objects ({ current: elem }).

Parameters

ParameterTypeDescription
refRefRef callback or MutableRefObject
valueanyNative GUI element or undefined on unmount

Returns

void


createGuiElement()

function createGuiElement(
parent: LuaGuiElement,
type: GuiElementType,
props: Props,
fiberId: number): LuaGuiElement;

Defined in: react/index.ts:372

Creates a new native Factorio LuaGuiElement inside a parent container. Segregates creation properties from post-creation properties based on ELEMENT_SCHEMA, applies styles and style overrides, pre-indexes event handlers for O(1) integer table dispatch, tags the element with __reactId, and attaches the ref.

Parameters

ParameterTypeDescription
parentLuaGuiElementNative Factorio GUI parent container
typeGuiElementTypeNative element type name (e.g. “button”, “frame”, “flow”)
propsPropsVirtual element props
fiberIdnumberUnique Fiber node ID

Returns

LuaGuiElement

The created native LuaGuiElement


updateGuiElement()

function updateGuiElement(
elem: LuaGuiElement,
props: Props,
fiberId: number,
prevProps?: Props): void;

Defined in: react/index.ts:428

Updates an existing native Factorio LuaGuiElement by diffing current props against previous props. Only writes modified values to the Factorio C++ engine boundary to minimize cross-language overhead. Reapplies style overrides if the prototype style changed, updates pre-indexed event handlers, and updates refs.

Parameters

ParameterTypeDescription
elemLuaGuiElementLive native LuaGuiElement
propsPropsNext virtual element props
fiberIdnumberUnique Fiber node ID
prevProps?PropsPrevious virtual element props

Returns

void


findFirstGuiElement()

function findFirstGuiElement(fiber: Fiber): any;

Defined in: react/index.ts:491

Recursively traverses a Fiber subtree to find the first real LuaGuiElement. This is needed because Functional Components do not own a native element directly.

Parameters

ParameterTypeDescription
fiberFiberTarget Fiber node

Returns

any

The first matching valid LuaGuiElement or undefined


destroyGuiElement()

function destroyGuiElement(elem: any): void;

Defined in: react/index.ts:511

Safely destroys a native Factorio GUI element if it exists and is still valid.

Parameters

ParameterTypeDescription
elemanyLuaGuiElement to destroy

Returns

void


beginHookRender()

function beginHookRender(fiber: Fiber, hydrating: boolean): void;

Defined in: react/index.ts:532

Prepares the global hook cursor before rendering a functional component.

Parameters

ParameterTypeDescription
fiberFiberActive Fiber node being rendered
hydratingbooleanTrue if hydrating from storage on game load

Returns

void


endHookRender()

function endHookRender(): void;

Defined in: react/index.ts:541

Cleans up the global hook cursor after component render.

Returns

void


useState()

Call Signature

function useState<S>(initialValue: (this: void) => NonFunction<S>): [S, Dispatch<SetStateAction<S>>];

Defined in: react/index.ts:567

Declares a stateful variable in a functional component. State is preserved in the serializable fiber.hooks array across renders and game saves. The setState updater closure is cached in transient.memoCache on initial mount, resulting in zero closure allocations on subsequent re-renders.

Type Parameters
Type Parameter
S
Parameters
ParameterType
initialValue(this: void) => NonFunction<S>
Returns

[S, Dispatch<SetStateAction<S>>]

A tuple of [currentState, setState]

Call Signature

function useState<S>(initialValue: NonFunction<S>): [S, Dispatch<SetStateAction<S>>];

Defined in: react/index.ts:568

Declares a stateful variable in a functional component. State is preserved in the serializable fiber.hooks array across renders and game saves. The setState updater closure is cached in transient.memoCache on initial mount, resulting in zero closure allocations on subsequent re-renders.

Type Parameters
Type Parameter
S
Parameters
ParameterType
initialValueNonFunction<S>
Returns

[S, Dispatch<SetStateAction<S>>]

A tuple of [currentState, setState]


flushPendingEffects()

function flushPendingEffects(): void;

Defined in: react/index.ts:605

Flushes all queued side-effects after the component tree and GUI elements are committed.

Returns

void


useEffect()

function useEffect(effect: EffectCallback, deps?: DependencyList): void;

Defined in: react/index.ts:650

Side-effect hook. Queued and executed in the commit phase after GUI elements are attached. Cleans up previous effect return callback before re-running or on unmount.

Parameters

ParameterType
effectEffectCallback
deps?DependencyList

Returns

void


useReducer()

function useReducer<S, A>(
reducer: (this: void, prevState: S, action: A) => S,
initialArg: NonFunction<S>,
init?: (this: void, initial: S) => NonFunction<S>): [S, (this: void, action: A) => void];

Defined in: react/index.ts:677

Reducer hook for managing complex state transitions. Dispatches actions to compute the next state based on the reducer function.

Type Parameters

Type Parameter
S
A

Parameters

ParameterTypeDescription
reducer(this: void, prevState: S, action: A) => SState transition function (prevState, action) => nextState
initialArgNonFunction<S>Initial state value
init?(this: void, initial: S) => NonFunction<S>Optional lazy initialization function

Returns

[S, (this: void, action: A) => void]

A tuple of [state, dispatch]


useMemo()

function useMemo<T>(factory: (this: void) => T, deps: DependencyList): T;

Defined in: react/index.ts:701

Caches a computed value in transient RAM memory (hook.memo). Recomputes the value only when one of the specified dependencies changes, or during game hydration if the RAM cache was reset.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
factory(this: void) => TPure function that computes the value
depsDependencyListDependency array for change detection

Returns

T

The memoized value


useCallback()

function useCallback<T>(callback: T, deps: DependencyList): T;

Defined in: react/index.ts:726

Returns a memoized version of the callback function that only changes if dependencies change.

Type Parameters

Type Parameter
T extends (this: void, …args: any[]) => any

Parameters

ParameterTypeDescription
callbackTFunction to memoize
depsDependencyListDependency array

Returns

T

The stable callback reference


useRef()

Call Signature

function useRef<T>(initialValue: T): object;

Defined in: react/index.ts:737

Returns a mutable ref object whose .current property is initialized to the passed argument. The returned object persists in transient RAM across the component’s lifetime.

Type Parameters
Type Parameter
T
Parameters
ParameterTypeDescription
initialValueTInitial value assigned to ref.current
Returns

object

A mutable container { current: T }

NameTypeDefined in
currentTreact/index.ts:737

Call Signature

function useRef<T>(): object;

Defined in: react/index.ts:738

Returns a mutable ref object whose .current property is initialized to the passed argument. The returned object persists in transient RAM across the component’s lifetime.

Type Parameters
Type ParameterDefault type
Tundefined
Returns

object

A mutable container { current: T }

NameTypeDefined in
currentTreact/index.ts:738

useDebouncedCallback()

function useDebouncedCallback<A>(callback: (this: void, ...args: A) => void, delayTicks?: number): (this: void, ...args: A) => void;

Defined in: react/index.ts:778

Returns a debounced callback function that postpones execution until delayTicks game ticks have elapsed since the last invocation. Uses the global bucketed scheduler. Automatically cancels any pending execution on component unmount.

Type Parameters

Type Parameter
A extends any[]

Parameters

ParameterTypeDefault valueDescription
callback(this: void, …args: A) => voidundefinedFunction to debounce
delayTicksnumber30Number of game ticks to wait before invocation (default: 30 ticks = 0.5s)

Returns

The debounced callback function

(this: void, …args: A) => void


useInterval()

function useInterval(callback: (this: void) => void, intervalTicks?: number): void;

Defined in: react/index.ts:849

Executes a periodic callback at the specified interval using the high-performance bucketed scheduler. Automatically pauses if intervalTicks is 0 or negative. Automatically deregisters the scheduled timer on component unmount or interval change.

Parameters

ParameterTypeDescription
callback(this: void) => voidCallback invoked every interval
intervalTicks?numberInterval in game ticks (e.g. 60 ticks = 1 second). Pass <= 0 or undefined to pause.

Returns

void


useWindow()

function useWindow(playerIndex: PlayerIndex, options?: UseWindowOptions): UseWindowReturn;

Defined in: react/index.ts:879

Comprehensive window management hook for top-level dialogs (WindowFrame). Handles opening, closing, keyboard shortcuts (‘E’/Escape), pinning persistence, auto-centering, and position memory across game sessions.

Parameters

ParameterTypeDescription
playerIndexPlayerIndexFactorio player index
options?UseWindowOptionsOptional window options configuration

Returns

UseWindowReturn

Window controller interface with close, pinned, setPinned, togglePin, onLocationChanged


useEntityLifecycle()

function useEntityLifecycle(entity: any, callbacks: EntityLifecycleCallbacks): void;

Defined in: react/index.ts:1047

Observes a LuaEntity lifecycle (destruction, mining, blueprint revival) and executes callbacks. Automatically tracks entity position, surface, and unit number to handle rebuilds and ghost revivals.

Parameters

ParameterTypeDescription
entityanyThe Factorio entity to track
callbacksEntityLifecycleCallbacksLifecycle callback handlers (onDestroyed, onRevived)

Returns

void


arePropsEqual()

function arePropsEqual(prevProps?: Props, nextProps?: Props): boolean;

Defined in: react/index.ts:1176

Compares component props for shallow equality to determine if reconciliation can be bailed out. Automatically ignores stable function callbacks and performs deep comparison on styles overrides.

Parameters

ParameterTypeDescription
prevProps?PropsPrevious props
nextProps?PropsNext props

Returns

boolean

True if props are functionally identical


scheduleUpdate()

function scheduleUpdate(fiber: Fiber): void;

Defined in: react/index.ts:1203

Marks a Fiber and its parent branch as dirty, and schedules a deferred sub-tick render pass via an ephemeral rendering.draw_line object destruction trigger.

Parameters

ParameterTypeDescription
fiberFiberThe Fiber node requesting a re-render

Returns

void


performDeferredUpdates()

function performDeferredUpdates(roots?: Record<RootId, ReactRootData | undefined>): void;

Defined in: react/index.ts:1238

Processes all dirty Fiber roots in a single batch pass, re-rendering modified components, committing DOM updates, and flushing all queued side-effects.

Parameters

ParameterTypeDescription
roots?Record<RootId, ReactRootData | undefined>Table of active React roots in global storage

Returns

void


reconcile()

function reconcile(
element: ReactElement,
oldFiber: Fiber,
parentElem: LuaGuiElement,
parentFiber?: Fiber,
root?: ReactRootData): Fiber;

Defined in: react/index.ts:1279

Core React reconciliation and diffing algorithm. Compares a new ReactElement virtual descriptor against an existing Fiber node. Evaluates bailouts, executes functional components, creates or mutates native GUI widgets, and recursively reconciles children.

Parameters

ParameterTypeDescription
elementReactElementVirtual React element descriptor
oldFiberFiberExisting Fiber node from previous render pass
parentElemLuaGuiElementNative Factorio GUI parent container
parentFiber?FiberDirect parent Fiber node in the component tree
root?ReactRootDataEnclosing React root metadata

Returns

Fiber

The updated or newly created Fiber node


createRoot()

function createRoot(container: LuaGuiElement, element: ReactElement): number;

Defined in: react/index.ts:1457

Mounts a root React element into a native Factorio GUI container (e.g. player.gui.screen).

Parameters

ParameterTypeDescription
containerLuaGuiElementNative Factorio GUI parent container
elementReactElementRoot ReactElement (e.g. <CombinatorWindow playerIndex={playerIndex} />)

Returns

number

Unique numeric Root ID


destroyRoot()

function destroyRoot(rootId: number): void;

Defined in: react/index.ts:1496

Unmounts a root React tree, disposes all child fibers and GUI elements, and removes the root entry from persistent global storage.

Parameters

ParameterTypeDescription
rootIdnumberRoot identifier returned by createRoot

Returns

void


hydrateFiber()

function hydrateFiber(
element: ReactElement,
fiber: Fiber,
parentElem: LuaGuiElement,
parentFiber?: Fiber,
root?: ReactRootData): void;

Defined in: react/index.ts:1522

Recursively hydrates an existing Fiber tree during game on_load. Restores non-serializable RAM transient state (event handlers, memo caches, and live LuaGuiElement C++ references) matching native DOM tags without modifying game storage or mutating the DOM.

Parameters

ParameterTypeDescription
elementReactElementRoot virtual element descriptor
fiberFiberRoot Fiber node loaded from storage.reactRoots
parentElemLuaGuiElementNative Factorio GUI container
parentFiber?FiberDirect parent Fiber node in the component tree
root?ReactRootDataEnclosing React root metadata

Returns

void


handleOnLoad()

function handleOnLoad(): void;

Defined in: react/index.ts:1613

Hydrates all active React roots during game on_load. Iterates all active roots stored in storage.reactRoots and re-attaches transient RAM state.

Returns

void


handleOnObjectDestroyed()

function handleOnObjectDestroyed(ev: OnObjectDestroyedEvent): void;

Defined in: react/index.ts:1634

Handles deferred subtick render trigger via object destruction. Invoked when the ephemeral rendering line object is destroyed to batch-flush all dirty updates.

Parameters

ParameterTypeDescription
evOnObjectDestroyedEventFactorio on_object_destroyed event payload

Returns

void


handleGuiEvent()

function handleGuiEvent(event: any): void;

Defined in: react/index.ts:1648

Global high-performance O(1) Factorio GUI event dispatcher. Resolves the target Fiber ID from event.element.tags.__reactId and dispatches directly to the pre-indexed handler in transient.handlers without string matching or tree traversal.

Parameters

ParameterTypeDescription
eventanyFactorio GUI event payload

Returns

void


bootstrapReact()

function bootstrapReact(): void;

Defined in: react/index.ts:1677

Bootstraps the React runtime by registering core Factorio event listeners: on_load hydration, sub-tick deferred render trigger, and all GUI interaction events.

Returns

void

References

areObjectsEqual

Re-exports areObjectsEqual