Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2.  
  3. class Memes extends Component {
  4.     constructor(props) {
  5.         super(props);
  6.  
  7.         this.state = {
  8.             hideMemes: false
  9.         };
  10.  
  11.         this.showMemes = this.showMemes.bind(this);
  12.         this.hideMemes = this.hideMemes.bind(this);
  13.     }
  14.  
  15.     showMemes() {
  16.         this.setState({ hideMemes: false });
  17.     }
  18.  
  19.     hideMemes() {
  20.         this.setState({ hideMemes: true });
  21.     }
  22.  
  23.     render() {
  24.         return (
  25.             <div>
  26.                 <button type="button" onClick={this.showMemes} >
  27.                     Show Memes
  28.                 </button>
  29.                 <button type="button" onClick={this.hideMemes} >
  30.                     Hide Memes
  31.                 </button>
  32.                 {
  33.                     this.state.showMemes ? <h1>Memes</h1> : null
  34.                 }
  35.             </div>
  36.         );
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement