Skip to content

Commit

Permalink
fix(usePrismicClient()): accept a type parameter to define which do…
Browse files Browse the repository at this point in the history
…cuments are supported by the client (e.g. `Content.AllDocumentTypes`) (#197)
  • Loading branch information
angeloashmore authored Aug 31, 2023
1 parent ca3f851 commit b16e968
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/usePrismicClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import { usePrismicContext } from "./usePrismicContext";
*
* @returns The `@prismicio/client` instance provided to `<PrismicProvider>`.
*/
export const usePrismicClient = (
explicitClient?: prismic.Client,
): prismic.Client => {
export const usePrismicClient = <
TDocuments extends prismic.PrismicDocument = prismic.PrismicDocument,
>(
explicitClient?: prismic.Client<TDocuments>,
): prismic.Client<TDocuments> => {
const context = usePrismicContext();

const client = explicitClient || context?.client;
Expand Down

0 comments on commit b16e968

Please sign in to comment.