R1ZEN / react-yandex-maps

Yandex.Maps API bindings for React (fork https://github.com/gribnoysup/react-yandex-maps)
https://pbe-react-yandex-maps.vercel.app
MIT License
120 stars 19 forks source link

Ошибка при закрытии карты на react18 #68

Open olga-alexandrovnaa opened 10 months ago

olga-alexandrovnaa commented 10 months ago

Warning: useEffect must not return anything besides a function, which is used for clean-up. You returned: [object Object] at http://localhost:5173/node_modules/.vite/deps/@pbe_react-yandex-maps.js?v=b2e994ed:45:20

Uncaught TypeError: destroy is not a function at safelyCallDestroy (react-dom.development.js:22932:5) at commitHookEffectListUnmount (react-dom.development.js:23100:11) at commitPassiveUnmountInsideDeletedTreeOnFiber (react-dom.development.js:25098:11) at commitPassiveUnmountEffectsInsideOfDeletedTree_begin (react-dom.development.js:25048:5) at commitPassiveUnmountEffects_begin (react-dom.development.js:24956:11) at commitPassiveUnmountEffects (react-dom.development.js:24941:3) at flushPassiveEffectsImpl (react-dom.development.js:27038:3) at flushPassiveEffects (react-dom.development.js:26984:14) at react-dom.development.js:26769:9 at workLoop (scheduler.development.js:266:34)

olga-alexandrovnaa commented 10 months ago

Сбой был вызван неправильной реализацией асинхронного хука React.

useEffect(async () => { useEffect(() => { getSitemapSettings(); }, []);

Armanio commented 8 months ago

@olga-alexandrovnaa Привет! А как ты решила проблему, не поделишься хаком?

Armanio commented 8 months ago

Разобрался.

Конкретно у меня было так: onLoad={onMapLoad} const onMapLoad = useCallback((ref): void => (ymap.current = ref), []); заменил на:

  const onMapLoad = useCallback((ref): void => {
    ymap.current = ref;
  }, []);