Hylozoic / hylo-evo

Hylo UI
Apache License 2.0
36 stars 10 forks source link

fix Can't perform React state update on unmounted component warning #1682

Closed KevinTriplett closed 2 months ago

KevinTriplett commented 2 months ago

We get this warning:

File: src/routes/GroupSettings/RolesSettingsTab/RolesSettingsTab.test.js console.error Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. in RoleList in Router (created by MemoryRouter) in MemoryRouter in Provider in LayoutFlagsProvider in Unknown

  479 |   useEffect(() => {
  480 |     dispatch(responsbilityFetcher({ roleId }))
> 481 |       .then((response) => setResponsibilitiesForRole(response?.payload?.data?.responsibilities || []))
      |                           ^
  482 |       .catch((e) => { console.error('Error fetching responsibilities for role ', e) })
  483 |   }, [])
  484 |

  at console.error (node_modules/@testing-library/react/dist/act-compat.js:55:34)
  at printWarning (node_modules/react-dom/cjs/react-dom.development.js:88:30)
  at error (node_modules/react-dom/cjs/react-dom.development.js:60:5)
  at warnAboutUpdateOnUnmountedFiberInDEV (node_modules/react-dom/cjs/react-dom.development.js:23161:5)
  at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:21169:5)
  at setResponsibilitiesForRole (node_modules/react-dom/cjs/react-dom.development.js:15660:5)
  at src/routes/GroupSettings/RolesSettingsTab/RolesSettingsTab.js:481:27