Skip to content

Commit 3443cdb

Browse files
authored
Merge pull request #141 from invertase/ehesp/dc-feedback
2 parents 762e2f7 + 5382ee4 commit 3443cdb

File tree

4 files changed

+144
-63
lines changed

4 files changed

+144
-63
lines changed

docs/react/data-connect/mutations.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ function Component() {
3333
}
3434
```
3535

36+
Additionally, you can provide a factory function to the mutation, which will be called with the mutation variables:
37+
38+
```tsx
39+
const createMovie = useDataConnectMutation((title: string) => createMovieRef({ title, reviewDate: Date.now() }));
40+
// ...
41+
createMovie.mutate("John Wick");
42+
```
43+
3644
## Invalidating Queries
3745

3846
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.

packages/react/src/data-connect/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { QueryKey } from "@tanstack/react-query";
12
import type { MutationResult, QueryResult } from "firebase/data-connect";
23

34
// Flattens a QueryResult data down into a single object.

0 commit comments

Comments
 (0)