Skip to content

Commit 04d8498

Browse files
committedJan 20, 2024
feat: add live-paragraph.jsx solution
1 parent b8c5bd4 commit 04d8498

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
 

‎solutions/live-paragraph.jsx

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React, { useState } from "react"
2+
import { createRoot } from "react-dom/client"
3+
4+
function LiveText() {
5+
const [text, setText] = useState("")
6+
7+
const onChange = ({ target: { value } }) => {
8+
setText(value)
9+
}
10+
return (
11+
<>
12+
<input type="text" onChange={onChange} value={text} />
13+
<p>{text}</p>
14+
</>
15+
)
16+
}
17+
18+
const root = createRoot(document.getElementById("root"))
19+
root.render(<LiveText />)

0 commit comments

Comments
 (0)