1

I am following this example - https://supabase.com/docs/guides/with-expo

The login and account creation works as expected.

The issue is on the accounts page the Session is returning at undefined even when a user is logged in.

Here is the code:

import { useState, useEffect } from 'react'
import { supabase } from '../lib/supabase'
import { StyleSheet, View, Alert } from 'react-native'
import { Button, Input } from 'react-native-elements'
import { Session } from '@supabase/supabase-js'

export default function Account({ session }: { session: Session }) {
  const [loading, setLoading] = useState(true)
  const [username, setUsername] = useState('')
  const [website, setWebsite] = useState('')
  const [avatarUrl, setAvatarUrl] = useState('')

  useEffect(() => {
    if (session) getProfile()
  }, [session])

  async function getProfile() {
    try {
      setLoading(true)
      if (!session?.user) throw new Error('No user on the session!')

herbie
  • 335
  • 2
  • 14

1 Answers1

-1

Fixed it.

The example is out of date, I should now use version 2.

Specifically this piece of code to get session from asyncStorage:

https://supabase.com/blog/supabase-js-v2
herbie
  • 335
  • 2
  • 14