MCPcopy Index your code
hub / github.com/TanStack/router / useCreateColumnMutation

Function useCreateColumnMutation

examples/react/start-trellaux/src/queries.ts:28–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26}
27
28export function useCreateColumnMutation() {
29 const queryClient = useQueryClient()
30 return useMutation({
31 mutationFn: createColumn,
32 onMutate: async (variables) => {
33 await queryClient.cancelQueries()
34 queryClient.setQueryData(
35 boardQueries.detail(variables.data.boardId).queryKey,
36 (board) =>
37 board
38 ? {
39 ...board,
40 columns: [
41 ...board.columns,
42 {
43 ...variables.data,
44 order: board.columns.length + 1,
45 id: Math.random() + '',
46 },
47 ],
48 }
49 : undefined,
50 )
51 },
52 })
53}
54
55export function useCreateItemMutation() {
56 const queryClient = useQueryClient()

Callers 1

NewColumnFunction · 0.90

Calls 1

useMutationFunction · 0.50

Tested by

no test coverage detected