Guest User

Untitled

a guest
Jun 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import './App.css'
  3.  
  4. class App extends Component {
  5. constructor (props){
  6. super(props)
  7. this.state = {
  8. text : ' state 1',
  9. inputText : null,
  10. }
  11. }
  12. render() {
  13. const handleText1= ()=>{
  14. this.setState({
  15. text : 'handleText1'
  16. })
  17. }
  18. const handleText2= ()=>{
  19. this.setState({
  20. text : 'handleText2'
  21. })
  22. }
  23. const handleInput = (e)=>{
  24. this.setState({
  25. inputText : e.target.value
  26. })
  27. }
  28. return (
  29. <div>
  30. {this.state.text}
  31. <button onClick = {handleText1}> text 1 </button>
  32. <button onClick = {handleText2}> text 2 </button>
  33. <br/>
  34. <input onChange={handleInput}/>
  35. <p> this is inputText {this.state.inputText} </p>
  36. </div>
  37. )
  38. }
  39. }
  40.  
  41. export default App
Add Comment
Please, Sign In to add comment