Download next.js/test/e2e/app-dir/actions/app/server/counter.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 972 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/actions/app/server/counter.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/app-dir/actions/app/server/counter.js
-
curl -L -o counter.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/actions/app/server/counter.js
972 Bytes
| 'use client' | |
| import { useState } from 'react' | |
| export default function Counter({ inc, dec, double, slowInc }) { | |
| const [count, setCount] = useState(0) | |
| return ( | |
| <div> | |
| <h1 id="count">{count}</h1> | |
| <button | |
| id="inc" | |
| onClick={async () => { | |
| const newCount = await inc(count) | |
| setCount(newCount) | |
| }} | |
| > | |
| +1 | |
| </button> | |
| <button | |
| id="slow-inc" | |
| onClick={async () => { | |
| const newCount = await slowInc(count) | |
| setCount(newCount) | |
| }} | |
| > | |
| +1 (Slow) | |
| </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> | |
| </div> | |
| ) | |
| } | |