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

    Function useProjectData

    • 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.

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

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

      Returns {
          projectData: T;
          projectDataIsInitialized: boolean;
          setProjectData: Dispatch<SetStateAction<T>>;
      }

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

      It's only possible to use this hook once per workspace view component tree. Use this hook if your view component only needs to store a small amount of project data. For larger amounts of data, consider using useProjectDataSlice instead, which allows splitting the project data into multiple named slices. Using multiple slices 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.