Skip to content

Commit

Permalink
fix: fix example code in UrqlProvider tsdoc. (#3748)
Browse files Browse the repository at this point in the history
Co-authored-by: Jovi De Croock <[email protected]>
  • Loading branch information
y-hsgw and JoviDeCroock authored Feb 4, 2025
1 parent 128a088 commit dbc7a5b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .changeset/beige-penguins-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@urql/next': patch
---

Update Provider TSDoc to reflect our advice on
instantiating the client within a React component.
27 changes: 16 additions & 11 deletions packages/next-urql/src/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const SSRContext = React.createContext<SSRExchange | undefined>(
*
* @example
* ```tsx
* import { useMemo } from 'react';
* import {
* UrqlProvider,
* ssrExchange,
Expand All @@ -26,19 +27,23 @@ export const SSRContext = React.createContext<SSRExchange | undefined>(
* createClient,
* } from '@urql/next';
*
* const ssr = ssrExchange();
* const client = createClient({
* url: 'https://trygql.formidable.dev/graphql/basic-pokedex',
* exchanges: [cacheExchange, ssr, fetchExchange],
* suspense: true,
* });
*
* export default function Layout({ children }: React.PropsWithChildren) {
* return (
* <UrqlProvider client={client} ssr={ssr}>
* const [client, ssr] = useMemo(() => {
* const ssr = ssrExchange();
* const client = createClient({
* url: 'https://trygql.formidable.dev/graphql/web-collections',
* exchanges: [cacheExchange, ssr, fetchExchange],
* suspense: true,
* });
*
* return [client, ssr];
* }, []);
*
* return (
* <UrqlProvider client={client} ssr={ssr}>
* {children}
* </UrqlProvider>
* );
* </UrqlProvider>
* );
* }
*
* ```
Expand Down

0 comments on commit dbc7a5b

Please sign in to comment.