Download next.js/test/e2e/app-dir/actions/app/use-transition/page.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 506 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/actions/app/use-transition/page.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/app-dir/actions/app/use-transition/page.js
-
curl -L -o page.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/actions/app/use-transition/page.js
506 Bytes
| 'use client' | |
| import { useTransition } from 'react' | |
| import { addToCart } from './action' | |
| export default function Page() { | |
| const [isPending, startTransition] = useTransition() | |
| return ( | |
| <div className="grid "> | |
| <h1>Transition is: {isPending ? 'pending' : 'idle'} </h1> | |
| <button | |
| id="action-button" | |
| onClick={() => { | |
| startTransition(async () => { | |
| await addToCart() | |
| }) | |
| }} | |
| > | |
| Trigger action | |
| </button> | |
| </div> | |
| ) | |
| } | |