Skip to content

Commit a6d28ef

Browse files
Update part6d.md
I fixed the code syntax for useMutation.
1 parent e384e7d commit a6d28ef

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/content/6/en/part6d.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ import { getNotes, createNote } from './requests'
224224
const App = () => {
225225
const queryClient = useQueryClient() // highlight-line
226226

227-
const newNoteMutation = useMutation(createNote, {
227+
const newNoteMutation = useMutation({
228+
mutationFn: createNote,
228229
onSuccess: () => { // highlight-line
229230
queryClient.invalidateQueries({ queryKey: ['notes'] }) // highlight-line
230231
},
@@ -258,7 +259,8 @@ import { getNotes, createNote, updateNote } from './requests' // highlight-line
258259
const App = () => {
259260
// ...
260261

261-
const updateNoteMutation = useMutation(updateNote, {
262+
const updateNoteMutation = useMutation({
263+
mutationFn: updateNote,
262264
onSuccess: () => {
263265
queryClient.invalidateQueries({ queryKey: ['notes'] })
264266
},
@@ -281,7 +283,8 @@ The current code for the application is in [GitHub](https://github.com/fullstack
281283
The application works well, and the code is relatively simple. The ease of making changes to the list of notes is particularly surprising. For example, when we change the importance of a note, invalidating the query <i>notes</i> is enough for the application data to be updated:
282284

283285
```js
284-
const updateNoteMutation = useMutation(updateNote, {
286+
const updateNoteMutation = useMutation({
287+
mutationFn: updateNote,
285288
onSuccess: () => {
286289
queryClient.invalidateQueries('notes') // highlight-line
287290
},
@@ -302,7 +305,8 @@ The change for the mutation adding a new note is as follows:
302305
const App = () => {
303306
const queryClient = useQueryClient()
304307

305-
const newNoteMutation = useMutation(createNote, {
308+
const newNoteMutation = useMutation({
309+
mutationFn: createNote,
306310
onSuccess: (newNote) => {
307311
const notes = queryClient.getQueryData(['notes']) // highlight-line
308312
queryClient.setQueryData(['notes'], notes.concat(newNote)) // highlight-line

0 commit comments

Comments
 (0)