Horje
Cursor.jsx:8 Uncaught TypeError: Cannot read properties of null (reading 'clientWidth') Code Example
Cursor.jsx:8 Uncaught TypeError: Cannot read properties of null (reading 'clientWidth')
const CustomCursor = () => {
    //follows the cursor
    const customRef = React.useRef(null)
   
    useEffect(() => {
      const onMouseMove = (e) => {
        const { clientX, clientY } = e
        const mouseX = clientX - customRef.current.clientWidth / 2
        const mouseY = clientY - customRef.current.clientHeight / 2
        customRef.current.style.transform = `translate3d(${mouseX}px, ${mouseY}px, 0)`
      }
      // add the event listener
      document.addEventListener('mousemove', onMouseMove)
      // cleanup function
      return () => {
        // remove the event listener when the component unmounts
        document.removeEventListener('mousemove', onMouseMove)
      }
    }, [])
  
    return (
      <div className="app-cursor" ref={customRef} />
    )
}




Javascript

Related
vuejs props declare prop with multiple types Code Example vuejs props declare prop with multiple types Code Example
condition inner populate mongoose Code Example condition inner populate mongoose Code Example
react toastify dark mode Code Example react toastify dark mode Code Example
jquery post docs.google.com/forms/ CORS Code Example jquery post docs.google.com/forms/ CORS Code Example
how to do multiple pages in angular Code Example how to do multiple pages in angular Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6