Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

remove event listener react hooks

useEffect(() => {
  if (collapsed) {
    return;
  }

  function handleKeyUp(event) {
    switch (event.key) {
      case "Escape":
        setCollapsed(true);
        break;
    }
  }

  window.addEventListener("keyup", handleKeyUp);
  return () => window.removeEventListener("keyup", handleKeyUp);
}, [collapsed]);
Comment

PREVIOUS NEXT
Code Example
Javascript :: Do not know how to serialize a BigInt 
Javascript :: header in axios 
Javascript :: exit application node js 
Javascript :: jquery cdn google 
Javascript :: jquery if else on click 
Javascript :: count occurrences of character in string javascript 
Javascript :: hasOwnProperty with more than one property 
Javascript :: js arrays check if there is intersection 
Javascript :: mongo create user 
Javascript :: add keyup event javascript 
Javascript :: extract filename from content-disposition header js 
Javascript :: change icon sapui5 
Javascript :: Sailsdock 
Javascript :: build ionic app for android livereload 
Javascript :: update node ubuntu 
Javascript :: get offset of element relative to parent 
Javascript :: inline z-index react 
Javascript :: js get meta content 
Javascript :: jetbrains font 
Javascript :: javascript tan 
Javascript :: javascript get label value 
Javascript :: javascript lerp 
Javascript :: moment js date diff 
Javascript :: find object length in javascript 
Javascript :: create text editor with react-redux 
Javascript :: ERR_OSSL_EVP_UNSUPPORTED 
Javascript :: react onclick new tab 
Javascript :: gettype js 
Javascript :: create folder by commend line 
Javascript :: check if mobile view javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =