Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Example react-user-management: Unsubscribe onAuthStateChange listener. (#27799)

Jens Hauke33a6bd439a0f
diff --git a/examples/user-management/react-user-management/src/App.jsx b/examples/user-management/react-user-management/src/App.jsx
index 3c212c4068a..e7dfc086f17 100644
--- a/examples/user-management/react-user-management/src/App.jsx
+++ b/examples/user-management/react-user-management/src/App.jsx
@@ -12,9 +12,11 @@ function App() {
setSession(session)
})
- supabase.auth.onAuthStateChange((_event, session) => {
+ const { data } = supabase.auth.onAuthStateChange((_event, session) => {
setSession(session)
})
+
+ return () => data.subscription.unsubscribe();
}, [])
return (