title: TypeError: Cannot set properties of undefined (setting 'transform')
body: <p>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?</p>
  <pre><code>const WorkPage = () =&gt; {
    const ref = useRef(null);
  
    useEffect(() =&gt; {
      let element = ref.current;
  
      const rotate = () =&gt; {
        element.style.transform = `translateX(${-window.pageYOffset}px)`
      };
  
      window.addEventListener('scroll', rotate)
      return () =&gt; window.removeEventListener('scroll', rotate)
    }, [])
  </code></pre>