We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a6d33d5 commit b8c5bd4Copy full SHA for b8c5bd4
solutions/color-dropdown.jsx
@@ -0,0 +1,21 @@
1
+import React, { useState } from "react"
2
+import { createRoot } from "react-dom/client"
3
+
4
+function ColorSelector() {
5
+ const colors = { red: "Red", blue: "Blue", green: "Green" }
6
+ const [color, setColor] = useState(colors.red)
7
+ const onChange = e => setColor(e.target.value)
8
+ return (
9
+ <>
10
+ <select onChange={onChange} value={color}>
11
+ <option value={colors.red}>{colors.red}</option>
12
+ <option value={colors.blue}>{colors.blue}</option>
13
+ <option value={colors.green}>{colors.green}</option>
14
+ </select>
15
+ {color && <p>{`You have selected: ${color}`}</p>}
16
+ </>
17
+ )
18
+}
19
20
+const root = createRoot(document.getElementById("root"))
21
+root.render(<ColorSelector />)
0 commit comments