Kvaser CanKing GUI Extensions SDK v7.4.0


Kvaser CanKing GUI Extensions SDK / hooks / useUndoSessionDataSlice

Function: useUndoSessionDataSlice()

useUndoSessionDataSlice<T>(id, slice, initialState?): [IUndoObject<T>, boolean]

Custom hook to manage undo/redo state using session data storage.

Type Parameters

T

T

The type of the state being managed, must be serializable to JSON.

Parameters

id

number

The unique id of the view. This is passed to the view component as the id prop.

slice

string

The slice name for the session data.

initialState?

IUndoState<T>

The initial undo state. Will be used if there is no existing session data.

Returns

[IUndoObject<T>, boolean]

[undoObject, loaded] - An undo object for managing state history and loaded flag.

Remarks

This hook triggers component re-renders whenever the state changes. This is useful for persisting undo/redo state across sessions.