Kvaser CanKing GUI Extensions SDK - v7.4.0
    Preparing search index...

    Function useProjectDataSlice

    • A hook for data that should be saved to the current project. The state is automatically saved to and restored from the main process.

      Type Parameters

      • T

      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 project data.

      • defaultValue: T | (() => T)

        The default value or a function that returns the default value.

      • OptionalloadedCallback: (value: T) => void

        Optional callback invoked once after data is loaded.

      Returns [T, Dispatch<SetStateAction<T>>, boolean]

      An object with a flag indicating if the project data has been initialized, the current project data and a setter callback.

      Use this hook to split your workspace view's project data into multiple named slices. This can improve performance and reduce memory usage and it also allows different parts of the component tree to independently load and save their project data. Make sure to use the workspace view component's id prop and to use unique slice names for each slice within the component tree.