====== Using props, state, and Binding ====== ===== Ouptut ===== {{ :reject:react_exe1.png?nolink&600 |}} ===== App.js ===== One thing to notice is we have use ''event.target.value'' inside one of the call back function the UserInput component. import React, { Component } from 'react'; import './App.css'; import UserInput from './UserInput/UserInput' import UserOutput from './UserOutput/UserOutput' import "./UserOutput/UserOutput.css" class App extends Component { state = { usernames: [ { name: "name1" }, { name: "name2" } ] } onButtonClicked = () => { this.setState({ usernames: [ { name: "name 11111" }, { name: "name 22222" } ] }) } onTextChanged = (event) => { this.setState({ usernames: [ { name: event.target.value }, { name: "name 22222" } ] }) } render() { return (

  1. Create TWO new components: UserInput and UserOutput
  2. UserInput should hold an input element, UserOutput two paragraphs
  3. Output multiple UserOutput components in the App component (any paragraph texts of your choice)
  4. Pass a username (of your choice) to UserOutput via props and display it there
  5. Add state to the App component (=> the username) and pass the username to the UserOutput component
  6. Add a method to manipulate the state (=> an event-handler method)
  7. Pass the event-handler method reference to the UserInput component and bind it to the input-change event
  8. Ensure that the new input entered by the user overwrites the old username passed to UserOutput
  9. Add two-way-binding to your input (in UserInput) to also display the starting username
  10. Add styling of your choice to your components/ elements in the components - both with inline styles and stylesheets
); } } export default App;
===== UserInput.js ===== import React from 'react'; const userInput = (props) =>{ return (
) } export default userInput;
===== UserOutput.js, UserOutput.css ===== import React from 'react'; import './UserOutput.css'; const userOutput = (props) => { return (

paragraphs 1: name is {props.name}

paragraph 2

) } export default userOutput;
.UserOutput{ border: 1px solid black; background-color: #eee; margin: 10px }