supabase-community / auth-ui

Pre-built Auth UI for React
https://supabase.com/docs/guides/auth/auth-helpers/auth-ui
MIT License
487 stars 121 forks source link

Fix: EmailAuth mounted ref not resetting during remount #93

Closed Flexicon closed 1 year ago

Flexicon commented 1 year ago

What kind of change does this PR introduce?

Fixes #79.

When running React 18+ in Strict mode during dev, the component will "mount, unmount, then remount again" in order to ensure components have reusable state (read more).

Because of this behaviour and the fact the isMounted ref is not set to reset in the component's useEffect, the flag is permanently set to false under certain circumstances. See the issue for more info.

What is the current behavior?

The isMounted ref is set to false immediately on mount because of the effect of strict mode.

What is the new behavior?

The isMounted ref is correctly reset back to true whenever the component is remounted or the authView changes.

Flexicon commented 1 year ago

@silentworks any chance you or some other maintainer could take a look at this? 🙏🏻