Skip to main content

@lexical/react/useLexicalSlot

Functions

useLexicalSlot()

useLexicalSlot<T>(editor, nodeKey, slotName): RefObject<T | null>

Defined in: packages/lexical-react/src/useLexicalSlot.ts:28

Experimental

Mounts a decorator host's named slot into the host's React-rendered chrome. A decorator host leaves its slot container detached during reconciliation (it owns no inline DOM layout of its own), so attach the returned ref to the element where the slot should live and this hook moves the container there after each render, before paint. It re-runs every render and is idempotent, so a slot added after the host's first render — or a container recreated by a remove/re-add — is picked up without extra wiring.

Type Parameters

T

T extends HTMLElement = HTMLElement

Parameters

editor

LexicalEditor

nodeKey

string

slotName

string

Returns

RefObject<T | null>