score:2

Accepted answer
export default function OlMap() {
  let mapDiv = useRef(null);
  useEffect(() => {
    olMap.setTarget(mapDiv.current)
    return () => olMap.setTarget(undefined);
  }, []);

  return (
    <div id='map' ref={mapDiv}>
    </div>
  )
}

score:1

useEffect(() => {map.setTarget(...)}, [mapRef.current])

Related Query

More Query from same tag