Answers for "react addeventlistener useeffect"

0

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]);
Posted by: Guest on June-02-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language