Download next.js/test/e2e/app-dir/actions/app/client/edge/page.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/actions/app/client/edge/page.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/app-dir/actions/app/client/edge/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/client/edge/page.js
1.71 kB
| 'use client' | |
| import { useState } from 'react' | |
| import double, { inc, dec, redirectAction, getHeaders } from '../actions' | |
| export default function Counter() { | |
| const [count, setCount] = useState(0) | |
| return ( | |
| <div> | |
| <h1>{count}</h1> | |
| <button | |
| id="inc" | |
| onClick={async () => { | |
| const newCount = await inc(count) | |
| setCount(newCount) | |
| }} | |
| > | |
| +1 | |
| </button> | |
| <button | |
| id="dec" | |
| onClick={async () => { | |
| const newCount = await dec(count) | |
| setCount(newCount) | |
| }} | |
| > | |
| -1 | |
| </button> | |
| <button | |
| id="double" | |
| onClick={async () => { | |
| const newCount = await double(count) | |
| setCount(newCount) | |
| }} | |
| > | |
| *2 | |
| </button> | |
| <form> | |
| <button | |
| id="redirect-relative" | |
| formAction={() => redirectAction('/redirect-target')} | |
| > | |
| redirect to a relative URL | |
| </button> | |
| </form> | |
| <form> | |
| <button | |
| id="redirect-absolute" | |
| formAction={() => | |
| redirectAction(`${location.origin}/redirect-target`) | |
| } | |
| > | |
| redirect to a absolute URL | |
| </button> | |
| </form> | |
| <form> | |
| <button | |
| id="redirect-external" | |
| formAction={() => | |
| redirectAction( | |
| 'https://next-data-api-endpoint.vercel.app/api/random?page' | |
| ) | |
| } | |
| > | |
| redirect external | |
| </button> | |
| </form> | |
| <form> | |
| <button id="get-headers" formAction={() => getHeaders()}> | |
| get headers | |
| </button> | |
| </form> | |
| </div> | |
| ) | |
| } | |
| export const runtime = 'edge' | |