Download react-query/examples/react/react-router/src/routes/destroy.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 477 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/react-router/src/routes/destroy.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/react-router/src/routes/destroy.tsx
-
curl -L -o destroy.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/react-router/src/routes/destroy.tsx
477 Bytes
| import { ActionFunctionArgs, redirect } from 'react-router-dom' | |
| import { deleteContact } from '../contacts' | |
| import { QueryClient } from '@tanstack/react-query' | |
| export const action = | |
| (queryClient: QueryClient) => | |
| async ({ params }: ActionFunctionArgs) => { | |
| if (!params.contactId) { | |
| throw new Error('No contact ID provided') | |
| } | |
| await deleteContact(params.contactId) | |
| queryClient.invalidateQueries({ queryKey: ['contacts'] }) | |
| return redirect('/') | |
| } | |