Your instance's schema from @cubicweb/client
Your CubicWeb client from @cubicweb/client
Parameters to describe how to build the query.
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
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.