Skip to main content

$getNodeByKeyOrThrow

function

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

function $getNodeByKeyOrThrow(key: NodeKey): LexicalNode function $getNodeByKeyOrThrow<N extends LexicalNode>(key: NodeKey): N

Import

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

Notes

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