Documentation Index
Fetch the complete documentation index at: https://mintlify.com/devhammed/react-gtk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
React GTK uses a custom React reconciler to transform React components into native GTK 4.0 widgets. This process bridges the declarative React paradigm with the imperative GTK widget system, enabling you to build desktop applications using familiar React patterns.The Rendering Process
Create Root
The rendering process begins by creating a root container using This function creates:
createRoot(), which initializes a GTK Application and React reconciler container.- A
Gtk.Applicationinstance with your application ID - A reconciler container linked to the GTK app
- A GLib MainLoop for event handling
Render Elements
Call When
render() to mount your React tree and activate the GTK application.render() is called:- A GLib MainLoop is created
- The GTK app’s
activatesignal is connected - The reconciler updates the container with your React element
- The application runs and enters the event loop
Component to Widget Conversion
React GTK converts your JSX elements to GTK widgets through the reconciler’s Each component type (like
createInstance() method.gtk-window, gtk-button) maps to a widget implementation class.Text Rendering
Text children in React GTK are automatically converted toGtkLabel widgets with markup support:
GtkLabel with Pango markup enabled.
Text instances are created with
useMarkup: true, allowing you to use Pango markup syntax like <b>bold</b> or <i>italic</i> directly in your text.Update Lifecycle
Prop Diffing
When component props change, React GTK calculates the minimal set of updates needed:- Compares old and new props
- Identifies added, removed, or changed properties
- Returns only the changed props (or
nullif nothing changed)
Committing Updates
Once prop changes are calculated, they’re applied to the native widget:Application Lifecycle
Activation
The GTK application activates whenrun() is called. This connects to the activate signal and updates the reconciler container:
Window Management
React GTK tracks all windows in the application. When a window closes, it checks if any windows remain visible:Example: Complete Rendering Flow
Here’s a complete example showing the rendering flow:createRoot()creates a GTK Application and reconciler containerrender()starts the GTK application and enters the event loop- On
activate, the reconciler creates aGtkWindowImplinstance - The
GtkButtonis created as a child of the window - When clicked, React updates the button’s label text
- The reconciler calculates the prop diff (label changed)
- The native GTK button widget is updated with the new label
