79265656

Date: 2024-12-09 16:03:59
Score: 1
Natty:
Report link

2024, using lodash.debounce

useEffect(() => {
  const debouncedResize = debounce(() => {
    mapRef.current?.resize();
  }, 0);

  const handleResize = () => {
    debouncedResize();
  };

  const resizer = new ResizeObserver(handleResize);

  if (mapContainerRef.current) {
    resizer.observe(mapContainerRef.current);
  }

  return () => {
    resizer.disconnect();
    debouncedResize.cancel();
  };
}, []);
Reasons:
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: morphoix