MCPcopy Create free account
hub / github.com/cosdensolutions/code / Form

Function Form

videos/long/react-playwright-tutorial/src/components/Form.tsx:5–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { useState } from "react";
4
5export default function Form() {
6 const [items, setItems] = useState<string[]>([]);
7 const [inputValue, setInputValue] = useState("");
8
9 return (
10 <div>
11 <h1 className="text-2xl font-bold">Form</h1>
12 <form
13 onSubmit={(e) => {
14 e.preventDefault();
15 setItems([...items, inputValue]);
16 setInputValue("");
17 }}
18 >
19 <label>
20 <input
21 type="text"
22 name="item"
23 value={inputValue}
24 onChange={(e) => setInputValue(e.target.value)}
25 placeholder="Enter item"
26 />
27 </label>
28 <button className="ml-2" type="submit">
29 Add
30 </button>
31 </form>
32 <ul data-testId="items-list">
33 {items.map((item, index) => (
34 <li key={index} data-testId="item">
35 {item}
36 </li>
37 ))}
38 </ul>
39 </div>
40 );
41}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected