React-google-login: 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.

Created on 31 Mar 2020  路  17Comments  路  Source: anthonyjgrove/react-google-login

Hi.

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.

I鈥檓 using logout hook now, but it didn鈥檛 clean up inside useEffect, causing memory leak. (ref)

In addition, google scripts are being added every time a component is re-rendered.

Most helpful comment

Still getting memory leaks warning

All 17 comments

Have you mind if I fix it?

A PR would be great

Still getting memory leaks warning

memory leaks warning is still there

I'm still getting the warning

me too, but it's not happened every time. I downgrade to 5.1.2 now and see if this warning is still there.

I checked the code and found it seems the setLoaded(true) in line 89 and 97 in use-google-login.js.
maybe can add isMountedRef by useRef like this page: https://www.debuggr.io/react-update-unmounted-component/
and check if isMountedRef.current is true before calling setLoaded(true)
but, it seems this method is anti-pattern.

I still had a problem.
But I didn't think it was just this library because it was mixed with other problems in the production I was making.

I checked the https://github.com/anthonyjgrove/react-google-login/issues/311#issuecomment-617521690. I think it's better to be fixed.
I'll reopen the issue.

Still the same? any chance for the fix? i mean, it's not a big deal, but good lib, and would be greate to have it perfectly fit in our apps

yup still there...

Any update on this?

Also having this issue when adding a logout button

I started have memory leaks problem after add this package

got the same issue as well

@zoripong Any ideas to fix it?

I had this issue with useEffect Any idea to fix it ?

Was this page helpful?
0 / 5 - 0 ratings