This is the part of my react application, where I've used a ref.current which is equal to null, then I'm changing it's property, I know like this is surely gonna give me error but in one of my friend's project with same react component WorkPage it's working fine. I'm so confused, is there any sort of fault in mine?
const WorkPage = () => {
const ref = useRef(null);
useEffect(() => {
let element = ref.current;
const rotate = () => {
element.style.transform = `translateX(${-window.pageYOffset}px)`
};
window.addEventListener('scroll', rotate)
return () => window.removeEventListener('scroll', rotate)
}, [])