Skip to content

Commit

Permalink
React Data Sync Client: Add ReactQuery dev tools (#41357)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamSarsfield authored Jan 30, 2025
1 parent a2a02b1 commit b614623
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
31 changes: 29 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Add React Query Devtools
2 changes: 2 additions & 0 deletions projects/js-packages/react-data-sync-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"devDependencies": {
"@automattic/jetpack-webpack-config": "workspace:*",
"@tanstack/react-query": "5.0.5",
"@tanstack/react-query-devtools": "5.0.5",
"react-dom": "^18.0.0",
"jest": "*",
"react": "18.3.1",
"tslib": "2.5.0",
Expand Down
11 changes: 7 additions & 4 deletions projects/js-packages/react-data-sync-client/src/DataSyncHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
useMutation,
QueryClientProvider,
} from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import React, { useRef, useEffect } from 'react';
import { z } from 'zod';
import { DataSync } from './DataSync';
Expand All @@ -29,10 +30,12 @@ export function invalidateQuery( key: string ) {
* @see https://tanstack.com/query/v5/docs/react/reference/QueryClientProvider
*/
export function DataSyncProvider( props: { children: React.ReactNode } ) {
return QueryClientProvider( {
client: queryClient,
...props,
} );
return React.createElement(
QueryClientProvider,
{ client: queryClient },
props.children,
React.createElement( ReactQueryDevtools )
);
}

/**
Expand Down

0 comments on commit b614623

Please sign in to comment.