Function useGetCubicWebEntity

  • Fetches the values for the entity of the given eid. Along with the loading state, it also returns the entity schema.

    Like useCubicWebForm, you can decide which relations/attributes to ignore.

    Type Parameters

    • E extends EntityRawSchemaArray

    • R extends RelationDefinitionRawSchemaArray<E>

    • EntityType extends string

    Parameters

    Returns UseGetCubicWebEntityData

    Example

    Here is an example usage. Please refer to the documentation of @cubicweb/client on how to create the schema and client parameters.

    As your instance's schema and client will not change in your app, you will usually want to wrap this hook so you don't have to pass those parameters each time.

    import {instanceSchema, client} from "./my-data"
    import {GetCubicWebEntityQueryParams, useGetCubicWebEntity} from "@cubicweb/react-form-utils"

    function useGetMyAppEntity(queryParams: GetCubicWebEntityQueryParams) {
    return useGetCubicWebEntity(
    instanceSchema,
    client,
    queryParams
    )
    }

    function MyShowComponent() {
    const {values, loading, entityTypeSchema} = useGetMyAppEntity(
    {
    type: "EntityType",
    eid: 1,
    omittedFields: ["atttribute_I_want_to_ignore"],
    includeObjectRelations: true,
    }
    )
    ...
    }

Generated using TypeDoc