Skip to main content

$getStateChange

function

Given two versions of a node and a stateConfig, compare their state values using `$getState(nodeVersion, stateConfig, NODE_STATE_DIRECT)`. If the values are equal according to `stateConfig.isEqual`, return `null`, otherwise return `[value, prevValue]`. This is useful for implementing updateDOM. Note that the `NODE_STATE_DIRECT` version argument is used for both nodes.

function $getStateChange<T extends LexicalNode, K extends string, V>(node: T, prevNode: T, stateConfig: StateConfig<K, V>): null | [value: V, prevValue: V]

Import

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

Notes

returns
`[value, prevValue]` if changed, otherwise `null`