Next.js Discord

Discord Forum

unable to pass ref in other component

Unanswered
Boykin Spaniel posted this in #help-forum
Open in Discord
Boykin SpanielOP
I'm trying to pass ref in my other component and I'm getting undefined value.

// page.jsx

const Map = dynamic(() => import("@/components/Map"),{
  ssr:false
})
  <Map {...props} ref={compRef} suppressHydrationWarning />


//Map.jsx

const Map = forwardRef((props, ref) => {
    const mapRef = useRef(null)
    const featureGroupRef = useRef(null)
    console.log("ref", ref?.current) // output undefined
}

0 Replies