()
| 3 | import { useState } from "react"; |
| 4 | |
| 5 | export 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected