-
|
I am working on an Admin project using 'blitz' , for managing the database tables. When I make a list of users, I want to switch the state of a user, but this causes the entire const [{ users, count }, { setQueryData, isLoading }] = usePaginatedQuery(getUsers, {
orderBy: { id: "asc" },
skip: ITEMS_PER_PAGE * (page - 1),
take: ITEMS_PER_PAGE,
})
const [updateUserMutation, { isLoading }] = useMutation(updateUser, {
onSuccess: async (user) => {
await setQueryData(user)
if (user.status) {
console.log('user activated')
})
} else {
console.log('user deactivated')
}
},
})
// The following code is used to associate state-switching functions for each user
const activateUser = () => updateUserMutation({ ...user, status: true })
const deactivateProduct = () => updateProductMutation({ ...product, status: false })The UI looks like this: ( the whole I don't want to re-render the entire component, is there any way get it done? If I were using But I wonder if there is a similar solution in Blitz? Thanks for any help ~ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
|
Beta Was this translation helpful? Give feedback.


setQueryDatainvalidates the query and causes a refetch (hence the re-render). If the refetch isn't necessary in your case you could pass{refetch: false}assetQueryData's options (haven't tried that, but from the docs it seems it can help). Otherwise, you can extract the part of the component that needs data, so that only the smaller part will re-render.