-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextForm.js
41 lines (26 loc) · 920 Bytes
/
TextForm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, {useState} from "react"
export default function TextForm( props){
const handleUpClick =() => {
let newText = text.toUpperCase();
setText(newText)
}
const handleLowClick =() => {
let newText = text.toLocaleLowerCase();
setText(newText)
}
const handleOnChange =(event) => {
setText(event.target.value)
}
const [text, setText] = useState("Enter your text");
return(
<div>
<h1>{props.heading}</h1>
<div className="mb-3">
<label for ="myBox" className="form-label">Example text area</label>
</div>
<textarea className="form-control" value={text} onChange={handleOnChange} id="mybox" rows="8"></textarea>
<button className="btn btn-primary" onClick={handleUpClick}> Convert to Upper</button>
<button className="btn btn-primary" onClick={handleLowClick}> Convert to Lower</button>
</div>
)
}