File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 11import './App.css' ;
22import Navbar from './components/Navbar' ;
3+ import TextForm from './components/TextForm' ;
34
45function App ( ) {
56 return (
67 < >
78 { /* <Navbar title="TextUtils" aboutText="About TextUtils" /> */ }
89 { /* <Navbar/> */ }
910 < Navbar title = "TextUtils" />
11+ < div className = "container my-3" >
12+ < TextForm heading = "Enter the text to analyze below" />
13+ </ div >
1014 </ >
1115 ) ;
1216}
Original file line number Diff line number Diff line change 1+ import React , { useState } from 'react'
2+
3+
4+ export default function TextForm ( props ) {
5+ const handleUpClick = ( ) => {
6+ // console.log("Uppercase was clicked: " + text);
7+ let newText = text . toUpperCase ( ) ;
8+ setText ( newText )
9+ }
10+
11+ const handleOnChange = ( event ) => {
12+ // console.log("On change");
13+ setText ( event . target . value )
14+ }
15+
16+ const [ text , setText ] = useState ( 'Enter text here2' ) ;
17+ // text = "new text"; // Wrong way to change the state
18+ // setText("new text"); // Correct way to change the state
19+ return (
20+ < div >
21+ < h1 > { props . heading } </ h1 >
22+ < div className = "mb-3" >
23+ < textarea className = "form-control" value = { text } onChange = { handleOnChange } id = "myBox" rows = "8" > </ textarea >
24+ </ div >
25+ < button className = "btn btn-primary" onClick = { handleUpClick } > Convert to Uppercase</ button >
26+ </ div >
27+ )
28+ }
You can’t perform that action at this time.
0 commit comments