Skip to content

queryClient.getQueryData() and queryClient.setQueryData should accept a string array #5

@nicemelbs

Description

@nicemelbs
const newNoteMutation = useMutation({
    mutationFn: createNote,

    onSuccess: (newNote) => {
      const notes = queryClient.getQueryData('notes')
      queryClient.setQueryData('notes', notes.concat(newNote))
    }
  })

In the lesson part 6d - Optimizing the Performance, and the provided code, 'notes' is passed as a string to const notes = queryClient.getQueryData('notes'), making notes equal to null. Creating a new note through the form saves it to db.json but the page doesn't get updated with the new entry.

If instead both queryClient.setQueryData and .getQueryData were given ['notes'], the page updates like it is described in the lesson.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions