Skip to main content

$getNodeByKey

function

Returns the node with the given key from the active EditorState (or the given EditorState), or null if it does not exist.

function $getNodeByKey(key: NodeKey, _editorState?: EditorState): LexicalNode | null function $getNodeByKey<T extends LexicalNode>(key: NodeKey, _editorState?: EditorState): T | null

Import

import { $getNodeByKey } from '@modular/sdk/editor';

Notes

deprecated
The type parameter is an unchecked and unsafe cast, equivalent to `$getNodeByKey(key) as T | null`, and will be removed in a future release. Call this function without a type argument and narrow the result with a type guard instead.