6 changed files with 94 additions and 25 deletions
@ -1,12 +1,33 @@
|
||||
import React from 'react'; |
||||
import './App.css'; |
||||
|
||||
function App() { |
||||
return ( |
||||
<div className="App"> |
||||
<h1>Oh hay, I'm a React App. Chap.</h1> |
||||
</div> |
||||
); |
||||
import React from 'react' |
||||
import UserInput from './UserInput/UserInput' |
||||
import UserOutput from './UserOutput/UserOutput' |
||||
import './App.css' |
||||
|
||||
class App extends React.Component { |
||||
constructor(props) { |
||||
super(props) |
||||
this.state = {username: "Placeholder"} |
||||
} |
||||
|
||||
handleUsernameChange(event) { |
||||
this.setState({ |
||||
username: event.target.value |
||||
}) |
||||
console.log(this.state.username) |
||||
console.log(event.target.value) |
||||
} |
||||
|
||||
render() { |
||||
return ( |
||||
<div className="App"> |
||||
<h1>Oy mate</h1> |
||||
<UserInput change={this.handleUsernameChange.bind(this)} username={this.state.username} /> |
||||
<UserOutput username={this.state.username} /> |
||||
<UserOutput username={this.state.username} /> |
||||
<UserOutput username={this.state.username} /> |
||||
</div> |
||||
) |
||||
} |
||||
} |
||||
|
||||
export default App; |
||||
export default App |
||||
|
||||
@ -0,0 +1,3 @@
|
||||
.UserInput { |
||||
border: 2px solid red; |
||||
} |
||||
@ -0,0 +1,27 @@
|
||||
import React from 'react' |
||||
import './UserInput.css' |
||||
|
||||
class UserInput extends React.Component { |
||||
constructor(props) { |
||||
super(props) |
||||
console.log("UserInput", props) |
||||
} |
||||
|
||||
style = {backgroundColor:"green"} |
||||
|
||||
render() { |
||||
return ( |
||||
<div> |
||||
<input
|
||||
className="UserInput" |
||||
type="text"
|
||||
onChange={this.props.change}
|
||||
value={this.props.username}
|
||||
style={this.style} |
||||
/> |
||||
</div> |
||||
) |
||||
} |
||||
} |
||||
|
||||
export default UserInput |
||||
@ -0,0 +1,8 @@
|
||||
.UserOutput { |
||||
width: 60%; |
||||
padding: 16px; |
||||
margin: 16px; |
||||
border: 2px solid black; |
||||
background-color: gray; |
||||
text-align: center; |
||||
} |
||||
@ -0,0 +1,19 @@
|
||||
import React from 'react'; |
||||
import './UserOutput.css' |
||||
|
||||
class UserOutput extends React.Component { |
||||
constructor(props) { |
||||
super(props) |
||||
console.log("UserOutput", props) |
||||
} |
||||
render() { |
||||
return ( |
||||
<div className="UserOutput"> |
||||
<p>Original username: Nevermind</p> |
||||
<p>New username: {this.props.username}</p> |
||||
</div> |
||||
) |
||||
} |
||||
} |
||||
|
||||
export default UserOutput; |
||||
Loading…
Reference in new issue