import React, { useEffect, useRef } from 'react' import styled from 'styles' export default function Cursor(): JSX.Element { const rCursor = useRef(null) useEffect(() => { function updatePosition(e: PointerEvent) { const cursor = rCursor.current cursor.setAttribute( 'transform', `translate(${e.clientX - 12} ${e.clientY - 10})` ) } document.body.addEventListener('pointermove', updatePosition) return () => { document.body.removeEventListener('pointermove', updatePosition) } }, []) return ( ) } const StyledCursor = styled('g', { position: 'absolute', zIndex: 1000, top: 0, left: 0, })