Download react-query/examples/react/suspense/src/components/Button.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 482 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/suspense/src/components/Button.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/suspense/src/components/Button.tsx
-
curl -L -o Button.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/suspense/src/components/Button.tsx
482 Bytes
| import React from 'react' | |
| import Spinner from './Spinner' | |
| export default function Button({ | |
| children, | |
| onClick, | |
| }: { | |
| children: React.ReactNode | |
| onClick: any | |
| }) { | |
| const [isPending, startTransition] = React.useTransition() | |
| const handleClick = (e: any) => { | |
| startTransition(() => { | |
| onClick(e) | |
| }) | |
| } | |
| return ( | |
| <> | |
| <button onClick={handleClick} disabled={isPending}> | |
| {children} {isPending ? <Spinner /> : null} | |
| </button> | |
| </> | |
| ) | |
| } | |