Skip to content

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

Cleanup the getSession usage

Andrew Smith03c7b28e7068
diff --git a/apps/reference/docs/guides/with-react.mdx b/apps/reference/docs/guides/with-react.mdx
index e28aafe878c..b130781488b 100644
--- a/apps/reference/docs/guides/with-react.mdx
+++ b/apps/reference/docs/guides/with-react.mdx
@@ -390,25 +390,14 @@ export default function App() {
const [session, setSession] = useState(null)
useEffect(() => {
- const fetchData = async () => {
- const { data } = await supabase.auth.getSession()
- return data
- }
-
- if (!session) {
- fetchData()
- .then(({ session }) => {
- setSession(session)
- })
- .catch((error) => {
- console.log(error)
- })
- }
+ supabase.auth.getSession().then(({ data: { session } }) => {
+ setSession(session)
+ })
supabase.auth.onAuthStateChange((_event, session) => {
setSession(session)
})
- }, [session])
+ }, [])
return (
<div className="container" style={{ padding: '50px 0 100px 0' }}>