El objeto Useref es posiblemente nulo

//Specify the type or assign a variable with the same type 
const overlayEl = useRef<HTMLDivElement>(null);
or
const overley E1 = useRef(document.createElement('div'));
Alexandre Dao