Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import logo from './logo.svg';
  3. import './App.css';
  4.  
  5. class App extends Component {
  6. state = {
  7. inputText: 'Hello World',
  8. listItem: [
  9. 'List Pertama',
  10. 'List Kedua',
  11. 'List ketiga'
  12. ]
  13. }
  14.  
  15. constructor(props) {
  16. super(props)
  17.  
  18. this.onChange = this.onChange.bind(this)
  19. }
  20.  
  21. onChange(event) {
  22. this.setState({
  23. inputText: event.target.value
  24. })
  25. }
  26.  
  27. render() {
  28. return (
  29. <div>
  30. <h1>{this.state.inputText}</h1>
  31. <input
  32. type="text"
  33. placeholder="Input nama"
  34. value={this.state.inputText}
  35. onChange={this.onChange} />
  36. <ul>
  37. {
  38. this.state.listItem.map((item,index) =>(
  39. <li key={index}>{item}</li>
  40. ))
  41. }
  42. </ul>
  43. </div>
  44. );
  45. }
  46. }
  47.  
  48. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement