Download next.js/test/e2e/app-dir/actions/app/error-handling/page.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 798 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/actions/app/error-handling/page.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/app-dir/actions/app/error-handling/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/error-handling/page.js
798 Bytes
| 'use client' | |
| import { useTransition } from 'react' | |
| import { action } from './actions' | |
| export default function Page() { | |
| const [, startTransition] = useTransition() | |
| return ( | |
| <main> | |
| <p> | |
| This button will call a server action and pass something unserializable | |
| like a class instance. We expect this action to error with a reasonable | |
| message explaning what happened | |
| </p> | |
| <button | |
| id="submit" | |
| onClick={async () => { | |
| await action(new Foo()) | |
| }} | |
| > | |
| Submit | |
| </button> | |
| <button | |
| id="submit-transition" | |
| onClick={async () => { | |
| startTransition(() => action()) | |
| }} | |
| > | |
| Action that triggers an error | |
| </button> | |
| </main> | |
| ) | |
| } | |
| class Foo { | |
| value = 42 | |
| } | |