Function: createPortal()
createPortal(
children,container,key?):ReactPortal
Defined in: portal.ts:29
Creates a React portal for rendering children into a different part of the widget tree.
Portals are useful for rendering dialogs, tooltips, or other floating content that should visually appear outside its parent component's boundaries.
Parameters
| Parameter | Type | Description |
|---|---|---|
children | ReactNode | The React elements to render in the portal |
container | Container | The target container widget to render into |
key? | string | null | Optional key for the portal element |
Returns
ReactPortal
A ReactPortal element
Example
import { createPortal } from "@gtkx/react";
const Modal = ({ container, children }) => {
return createPortal(
<GtkWindow modal>
{children}
</GtkWindow>,
container
);
};