When using useRef as DOMElemenet array type this error occured.
const checkPointRef = useRef<HTMLDivElement[]>([]);
<div ref={(elem) => (checkPointRef.current[0] = elem)} />
As error says, 'elem' variable, which refers to div element, can be null. So the correct type for the useRef([]) would be
<(HTMLDivElement | null)>[]
const checkPointRef = useRef<(null | HTMLDivElement)[]>([]);