useCollectionItemById

💡 Use this hook to get the selected collection item.

Hooks Sample Code

...
import useCollectionItemById from "mojito-hooks/useCollectionItemById";

function App {
    const { item, isLoading } = useCollectionItemById();

    if(isLoading) return <Loader />;

    if(item) return (
        <div>
            <h1>{item.name}</h1>
            <DrawCollectionItem item={item} />
        </div>
    );

    return <div>No collection item available</div>
}

Parameters

PropertyDescriptionTypeDefault
idThe id of the collection item.String-

Result

PropertyDescriptionType
itemThe collection item.MojitoCollectionItem
isLoadingDisplay request loading status, provided for convenience.Boolean
errorThe error object for the query, if an error was thrown.Error
refetchA function to manually refetch the query.(options: T) => Promise<U>
queryResultOriginal React-Query query result.QueryResult<T>