Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react addeventlistener useeffect

//101-Example
const callback = useCallback((event: any) => {
      event.data.status === "complete" ? setProgress(0) : setProgress(event.data.uploadProgress);
    },[])
  
  useEffect(() => {
    window.addEventListener("file-upload", callback);
    return () => window.removeEventListener("file-upload", callback);
  }, [window, callback]);
Comment

add event listener in react useeffect

const callback = useCallback((event: any) => {
      event.data.status === "complete" ? setProgress(0) : setProgress(event.data.uploadProgress);
    },[])
  
  useEffect(() => {
    window.addEventListener("file-upload", callback);
    return () => window.removeEventListener("file-upload", callback);
  }, [window, callback]);
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript copy some properties from one object to another 
Javascript :: how to remove all child elements in javascript 
Javascript :: settimeout javascript see how much time is left 
Javascript :: what is reactjs 
Javascript :: js convert to fraction 
Javascript :: javascript element distance from top 
Javascript :: create react app deployment heroku 
Javascript :: nodejs catch uncaught exception 
Javascript :: iterate object in react 
Javascript :: jquery remove multiple classes 
Javascript :: javascript generate random numbers 
Javascript :: addeventlistener js select item 
Javascript :: converting javascript object to json 
Javascript :: how to disable copy paste in input js 
Javascript :: mysql json search array of objects 
Javascript :: javascript find all matches in array 
Javascript :: count number of word in javascript 
Javascript :: string reverse javascript 
Javascript :: is object 
Javascript :: jquery on modal close event 
Javascript :: $ is not a function 
Javascript :: javascript break with for Loop 
Javascript :: moment().toDate(); 
Javascript :: regex match exact string 
Javascript :: array to string javascript 
Javascript :: currying javascript sum 
Javascript :: javascript dynamic import 
Javascript :: how to get console text in cypress 
Javascript :: owl carousel next previous button 
Javascript :: laravel react 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =