Guest User

Untitled

a guest
Jul 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. import React, { Component } from 'react';
  2.  
  3. class Homepage extends Component {
  4. constructor( props ){
  5. super( props )
  6. this.state = {show : true};
  7. this.showHide = this.showHide.bind(this)
  8. }
  9. render() {
  10. return (
  11. <section id="content">
  12. <div className="top-content">
  13. <div className="container">
  14. <h1>React</h1>
  15. <h2>A JavaScript library for building user interfaces</h2>
  16. </div>
  17. </div>
  18. <div className="container">
  19. <div>
  20. <div>
  21. <h3>Declarative</h3>
  22. <button onClick={this.showHide} className="button-primary btn">{this.changeName()}</button>
  23. { this.state.show &&
  24. <div>
  25. <p>text</p>
  26. <p>text</p>
  27. </div>
  28. }
  29. </div>
  30. <div>
  31. <h3>Component-Based</h3>
  32. <button onClick={this.showHide} className="button-primary btn">{this.changeName()}</button>
  33. { this.state.show &&
  34. <div>
  35. <p>text</p>
  36. <p>text</p>
  37. </div>
  38. }
  39. </div>
  40. <div>
  41. <h3>Learn Once, Write Anywhere</h3>
  42. <button onClick={this.showHide} className="button-primary btn">{this.changeName()}</button>
  43. { this.state.show &&
  44. <div>
  45. <p>text</p>
  46. <p>text</p>
  47. </div>
  48. }
  49. </div>
  50. </div>
  51. </div>
  52. </section>
  53. );
  54. }
  55. changeName(){
  56. let text = "text "
  57. text += this.state.show === true ? "hide" : "show";
  58. return text;
  59. }
  60. showHide(){
  61. const { show } = this.state;
  62. this.setState( { show : !show})
  63. }
  64. }
  65. export default Homepage;
Add Comment
Please, Sign In to add comment