|
1 | | -import React from 'react'; |
| 1 | +import React, { useState } from 'react'; |
2 | 2 | import logo from './logo.svg'; |
3 | 3 | import './App.css'; |
| 4 | +import UserInput from './UserInput/UserInput'; |
| 5 | +import UserOutput from './UserOutput/UserOutput'; |
| 6 | + |
| 7 | +import ValidationComponent from './ValidationComponent/ValidationComponent'; |
| 8 | +import CharComponent from './CharComponent/CharComponent'; |
4 | 9 |
|
5 | 10 | function App() { |
| 11 | + const [text, setText] = useState("Hola"); |
| 12 | + |
| 13 | + const updateText = ev => setText(ev.target.value); |
| 14 | + |
| 15 | + const deleteLetter = ix => { |
| 16 | + const textChars = text.split(''); |
| 17 | + textChars.splice(ix, 1); |
| 18 | + setText(textChars.join('')); |
| 19 | + } |
| 20 | + |
6 | 21 | return ( |
7 | 22 | <div className="App"> |
8 | 23 | <header className="App-header"> |
9 | | - <img src={logo} className="App-logo" alt="logo" /> |
10 | | - <p> |
11 | | - Edit <code>src/App.js</code> and save to reload. |
12 | | - </p> |
13 | | - <a |
14 | | - className="App-link" |
15 | | - href="https://reactjs.org" |
16 | | - target="_blank" |
17 | | - rel="noopener noreferrer" |
18 | | - > |
19 | | - Learn React |
20 | | - </a> |
| 24 | + <input onChange={updateText} value={text}></input> |
| 25 | + <p>The word is {text}!</p> |
| 26 | + <ValidationComponent length={text.length}></ValidationComponent> |
| 27 | + {text.split('').map((c, ix) => ( |
| 28 | + <CharComponent |
| 29 | + key={ix} |
| 30 | + letter={c} |
| 31 | + click={() => deleteLetter(ix)}> |
| 32 | + </CharComponent>) |
| 33 | + ) |
| 34 | + } |
| 35 | + {/* <UserInput username={username} changeUsernameHandler={setUsername}></UserInput> |
| 36 | + <UserOutput username={username}></UserOutput> |
| 37 | + <UserOutput></UserOutput> |
| 38 | + <UserOutput></UserOutput> */} |
21 | 39 | </header> |
22 | 40 | </div> |
23 | 41 | ); |
|
0 commit comments