SHARE
TWEET

Untitled

a guest Jun 25th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if(event1){
  2.  state=true
  3.  return <Component1 open="state">
  4. }
  5. //same code
  6. if(event2){...}
  7. // same code
  8. if(event3){...}
  9.      
  10. <Component1 />
  11. <Component2 />
  12. <component3 />
  13.      
  14. <Component1 open={this.state.open} />
  15. <Component2 open={this.state.open} />
  16. <component3 open={this.state.open} />
  17.      
  18. class Index extends Component {
  19. constructor(props){
  20. super(props);
  21.  this.state = {
  22.   open = false
  23.  }
  24. }
  25.  
  26. handleClose = () => {
  27.  this.setState({
  28.    open: false
  29.   })
  30. }
  31.  
  32. handleOpen = () => {
  33.   this.setState({
  34.     open: true
  35.   })
  36. }
  37.  
  38. render(){
  39.   let event1 = "string";
  40.   let event2 = "string";
  41.   let event3 = "string";
  42.   let receptacleEvent = [];
  43.   document.onkeydown = event => {
  44.   return (
  45.     receptacleEvent.push(event.key)
  46.     if (receptacle.toString().indexOf(event1) >=0){
  47.       this.handleOpen()
  48.       return <Component1 open={this.state.open} close={this.handleClose.bind(this) />
  49.     }
  50.     if (receptacle.toString().indexOf(event2) >=0){
  51.       this.handleOpen()
  52.       return <Component2 open={this.state.open} close={this.handleClose.bind(this) />
  53.     }
  54.     if (receptacle.toString().indexOf(event3) >=0){
  55.       this.handleOpen()
  56.       return <Component3 open={this.state.open} close={this.handleClose.bind(this) />
  57.     }
  58.    )
  59.   }
  60.  }
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top