[**Kvaser CanKing GUI Extensions SDK v7.4.0**](../../README.md)

***

[Kvaser CanKing GUI Extensions SDK](../../modules.md) / [hooks](../README.md) / useUndoSessionDataSlice

# Function: useUndoSessionDataSlice()

> **useUndoSessionDataSlice**\<`T`\>(`id`, `slice`, `initialState?`): \[[`IUndoObject`](../interfaces/IUndoObject.md)\<`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`](../interfaces/IUndoState.md)\<`T`\>

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

## Returns

\[[`IUndoObject`](../interfaces/IUndoObject.md)\<`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.
