Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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]);
Source by codedaily.io #
 
PREVIOUS NEXT
Tagged: #add #event #listener #react #useeffect
ADD COMMENT
Topic
Name
2+4 =