Skip to content

Commit 950213a

Browse files
authored
Merge pull request #137 from HassanBahati/rename-dc-hooks-upgrade-firebase
2 parents 5ce6daf + 27062f3 commit 950213a

33 files changed

+473
-473
lines changed

dataconnect-sdk/js/default-connector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"./package.json": "./package.json"
2121
},
2222
"peerDependencies": {
23-
"firebase": "^10.14.0"
23+
"firebase": "^10.14.0 || ^11.0.0"
2424
}
2525
}

docs.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@
117117
"group": "Hooks",
118118
"pages": [
119119
{
120-
"title": "useConnectQuery",
121-
"href": "/react/data-connect/hooks/useConnectQuery"
120+
"title": "useDataConnectQuery",
121+
"href": "/react/data-connect/hooks/useDataConnectQuery"
122122
},
123123
{
124-
"title": "useConnectMutation",
125-
"href": "/react/data-connect/hooks/useConnectMutation"
124+
"title": "useDataConnectMutation",
125+
"href": "/react/data-connect/hooks/useDataConnectMutation"
126126
}
127127
]
128128
}

docs/react/data-connect/hooks/useConnectMutation.mdx renamed to docs/react/data-connect/hooks/useDataConnectMutation.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: useConnectMutation
2+
title: useDataConnectMutation
33
---
44

5-
`useConnectMutation` is a hook designed to simplify handling mutations (creating, updating, deleting) with Firebase Data Connect.
5+
`useDataConnectMutation` is a hook designed to simplify handling mutations (creating, updating, deleting) with Firebase Data Connect.
66

77
See [mutations](/react/data-connect/mutations) for more information.
88

@@ -16,12 +16,12 @@ See [mutations](/react/data-connect/mutations) for more information.
1616
## Usage
1717

1818
```jsx
19-
import { useConnectQuery } from "@tanstack-query-firebase/react/data-connect";
19+
import { useDataConnectQuery } from "@tanstack-query-firebase/react/data-connect";
2020
import { createMovieRef } from "@your-package-name/your-connector";
2121

2222
function Component() {
2323
const { mutate, isPending, isSuccess, isError, error } =
24-
useConnectMutation(createMovieRef);
24+
useDataConnectMutation(createMovieRef);
2525

2626
const handleFormSubmit = (e: React.FormEvent) => {
2727
e.preventDefault();

docs/react/data-connect/hooks/useConnectQuery.mdx renamed to docs/react/data-connect/hooks/useDataConnectQuery.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: useConnectQuery
2+
title: useDataConnectQuery
33
---
44

5-
`useConnectQuery` is a hook designed to simplify data fetching and state management with Firebase Data Connect.
5+
`useDataConnectQuery` is a hook designed to simplify data fetching and state management with Firebase Data Connect.
66

77
See [querying](/react/data-connect/querying) for more information.
88

@@ -16,11 +16,11 @@ See [querying](/react/data-connect/querying) for more information.
1616
## Usage
1717

1818
```jsx
19-
import { useConnectQuery } from "@tanstack-query-firebase/react/data-connect";
19+
import { useDataConnectQuery } from "@tanstack-query-firebase/react/data-connect";
2020
import { listMoviesQuery } from "@your-package-name/your-connector";
2121

2222
function Component() {
23-
const { data, isPending, isSuccess, isError, error } = useConnectQuery(
23+
const { data, isPending, isSuccess, isError, error } = useDataConnectQuery(
2424
listMoviesQuery()
2525
);
2626

docs/react/data-connect/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ connectDataConnectEmulator(dataConnect, "localhost", 9399);
3131
The package exports are available via the `@tanstack-query-firebase/react` package under the `data-connect` namespace:
3232

3333
```ts
34-
import { useConnectQuery } from "@tanstack-query-firebase/react/data-connect";
34+
import { useDataConnectQuery } from "@tanstack-query-firebase/react/data-connect";
3535
```
3636

3737
## Basic Usage
3838

39-
To use the Tanstack Query Firebase hooks for Data Connect, you can use the `useConnectQuery` hook to fetch data from the database:
39+
To use the Tanstack Query Firebase hooks for Data Connect, you can use the `useDataConnectQuery` hook to fetch data from the database:
4040

4141
```tsx
42-
import { useConnectQuery } from "@tanstack-query-firebase/react/data-connect";
42+
import { useDataConnectQuery } from "@tanstack-query-firebase/react/data-connect";
4343
import { listMoviesRef } from "../../dataconnect/default-connector";
4444

4545
function Component() {
46-
const { data, isPending, isSuccess, isError, error } = useConnectQuery(
46+
const { data, isPending, isSuccess, isError, error } = useDataConnectQuery(
4747
listMoviesRef()
4848
);
4949

docs/react/data-connect/mutations.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ description: Learn how to mutate data in Firebase Data Connect using the Tanstac
55

66
## Mutating Data
77

8-
To mutate data in Firebase Data Connect, you can use the `useConnectMutation` hook.
8+
To mutate data in Firebase Data Connect, you can use the `useDataConnectMutation` hook.
99

1010
```tsx
11-
import { useConnectMutation } from "@tanstack-query-firebase/react/data-connect";
11+
import { useDataConnectMutation } from "@tanstack-query-firebase/react/data-connect";
1212
import { createMovieRef } from "@dataconnect/default-connector";
1313

1414
function Component() {
15-
const createMovie = useConnectMutation(
15+
const createMovie = useDataConnectMutation(
1616
createMovieRef
1717
);
1818

@@ -38,7 +38,7 @@ function Component() {
3838
The hook provides an additional [mutation option](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation) called `invalidate`. This option accepts a list of query references which will be automatically invalidated when the mutation is successful.
3939

4040
```tsx
41-
const createMovie = useConnectMutation(createMovieRef, {
41+
const createMovie = useDataConnectMutation(createMovieRef, {
4242
invalidate: [getMovieRef],
4343
});
4444
```
@@ -57,7 +57,7 @@ getMovieRef({ id: "2"});
5757
You can also provide explicit references to the invalidate array, for example:
5858

5959
```tsx
60-
const createMovie = useConnectMutation(createMovieRef, {
60+
const createMovie = useDataConnectMutation(createMovieRef, {
6161
invalidate: [getMovieRef({ id: "1" })],
6262
});
6363
```
@@ -71,7 +71,7 @@ In this case only the query reference `getMovieRef({ id: "1" })` will be invalid
7171
Along with the data, the hook will also return the `ref`, `source`, and `fetchTime` metadata from the mutation.
7272

7373
```tsx
74-
const createMovie = useConnectMutation(createMovieRef);
74+
const createMovie = useDataConnectMutation(createMovieRef);
7575

7676
const data = await createMovie.mutateAsync({
7777
title: 'John Wick',

docs/react/data-connect/querying.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ description: Learn how to query data from Firebase Data Connect using the Tansta
55

66
## Querying Data
77

8-
To query data from Firebase Data Connect, you can use the `useConnectQuery` hook. This hook will automatically infer the data type from the connector and the query and automtically create a [query key](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for the query.
8+
To query data from Firebase Data Connect, you can use the `useDataConnectQuery` hook. This hook will automatically infer the data type from the connector and the query and automtically create a [query key](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for the query.
99

1010
```tsx
11-
import { useConnectQuery } from "@tanstack-query-firebase/react/data-connect";
11+
import { useDataConnectQuery } from "@tanstack-query-firebase/react/data-connect";
1212
import { listMoviesRef } from "@dataconnect/default-connector";
1313

1414
function Component() {
15-
const { data, isPending, isSuccess, isError, error } = useConnectQuery(
15+
const { data, isPending, isSuccess, isError, error } = useDataConnectQuery(
1616
listMoviesRef()
1717
);
1818
}
1919
```
2020

2121
### Query options
2222

23-
To leverage the full power of Tanstack Query, you can pass in query options to the `useConnectQuery` hook, for example to refetch the query on a interval:
23+
To leverage the full power of Tanstack Query, you can pass in query options to the `useDataConnectQuery` hook, for example to refetch the query on a interval:
2424

2525
```tsx
26-
const { data, isPending, isSuccess, isError, error } = useConnectQuery(
26+
const { data, isPending, isSuccess, isError, error } = useDataConnectQuery(
2727
listMoviesRef(),
2828
{
2929
refetchInterval: 1000,
@@ -35,10 +35,10 @@ The hook extends the [`useQuery`](https://tanstack.com/query/latest/docs/framewo
3535

3636
### Overriding the query key
3737

38-
To override the query key, you can pass in a custom query key to the `useConnectQuery` hook:
38+
To override the query key, you can pass in a custom query key to the `useDataConnectQuery` hook:
3939

4040
```tsx
41-
const { data, isPending, isSuccess, isError, error } = useConnectQuery(
41+
const { data, isPending, isSuccess, isError, error } = useDataConnectQuery(
4242
getMovieRef({ id: "1" }),
4343
{
4444
queryKey: ["movies", "1"],
@@ -59,7 +59,7 @@ const movies = await executeQuery(listMoviesRef());
5959
// ...
6060

6161
function Component(props: { movies: QueryResult<ListMoviesData, unknown> }) {
62-
const { data, isPending, isSuccess, isError, error } = useConnectQuery(
62+
const { data, isPending, isSuccess, isError, error } = useDataConnectQuery(
6363
props.movies
6464
);
6565
}
@@ -72,7 +72,7 @@ The hook will immediately have data available, and immediately refetch the data
7272
Along with the data, the hook will also return the `ref`, `source`, and `fetchTime` metadata from the query.
7373

7474
```tsx
75-
const { data } = useConnectQuery(listMoviesRef());
75+
const { data } = useDataConnectQuery(listMoviesRef());
7676

7777
console.log(data?.ref);
7878
console.log(data?.source);

docs/react/data-connect/server-side-rendering.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default function MoviesRoute({
4545
}
4646

4747
function Movies() {
48-
const movies = useConnectQuery(listMoviesRef());
48+
const movies = useDataConnectQuery(listMoviesRef());
4949

5050
if (movies.isLoading) {
5151
return <div>Loading...</div>;
@@ -94,13 +94,13 @@ export default async function PostsPage() {
9494
}
9595

9696
function Movies() {
97-
const movies = useConnectQuery(listMoviesRef());
97+
const movies = useDataConnectQuery(listMoviesRef());
9898

9999
// ...
100100
}
101101
```
102102

103103
### Gotchas
104104

105-
- If you opt-in to providing a custom `queryKey` to either the prefetched data or the `useConnectQuery` hook, you must ensure that the `queryKey` is the same for both.
105+
- If you opt-in to providing a custom `queryKey` to either the prefetched data or the `useDataConnectQuery` hook, you must ensure that the `queryKey` is the same for both.
106106
- By default, the client will always refetch data in the background. If this behaviour is not desired, you can set the `staleTime` option in your Query Client or hook options.

examples/react-example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@tanstack/react-query": "^5.55.4",
1313
"@tanstack-query-firebase/react": "link:../../packages/react",
1414
"@dataconnect/default-connector": "workspace:*",
15-
"firebase": "^10.14.1",
15+
"firebase": "^11.0.0",
1616
"next": "15.1.0",
1717
"react": "^19.0.0",
1818
"react-dom": "^19.0.0"

examples/react-example/src/examples/data-connect.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
import { createMovieRef, listMoviesRef } from "@dataconnect/default-connector";
44
import {
5-
useConnectMutation,
6-
useConnectQuery,
5+
useDataConnectMutation,
6+
useDataConnectQuery,
77
} from "@tanstack-query-firebase/react/data-connect";
88

99
import "@/firebase";
1010

1111
export function Movies() {
12-
const movies = useConnectQuery(listMoviesRef());
12+
const movies = useDataConnectQuery(listMoviesRef());
1313

14-
const addMovie = useConnectMutation(createMovieRef, {
14+
const addMovie = useDataConnectMutation(createMovieRef, {
1515
invalidate: [listMoviesRef],
1616
});
1717

0 commit comments

Comments
 (0)