event listener in useeffect code example
Example: 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]);