mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Docs - [React Native Expo user management guide](https://supabase.com/docs/guides/getting-started/tutorials/with-expo-react-native) ## What is the new behavior? Guide has been updated to be in line with #42269 - Removing `@rneui/themed` package and using native components. - Update guide screenshot. - Main stylesheet for the example. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Documentation - Updated Expo React Native tutorial with modernized component approach using React Native primitives and centralized styling patterns. - Simplified codebase examples with consistent formatting and improved maintainability. - Core functionality preserved with updated implementation patterns. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Chris Chinchilla <chris.ward@supabase.io> Co-authored-by: Chris Chinchilla <chris@chrischinchilla.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
35 lines
966 B
TypeScript
35 lines
966 B
TypeScript
import { useState, useEffect } from 'react'
|
|
import { supabase } from './lib/supabase'
|
|
import Auth from './components/Auth'
|
|
import Account from './components/Account'
|
|
import { View } from 'react-native'
|
|
|
|
export default function App() {
|
|
const [userId, setUserId] = useState<string | null>(null)
|
|
const [email, setEmail] = useState<string | undefined>(undefined)
|
|
|
|
useEffect(() => {
|
|
supabase.auth.getClaims().then(({ data: { claims } }) => {
|
|
if (claims) {
|
|
setUserId(claims.sub)
|
|
setEmail(claims.email)
|
|
}
|
|
})
|
|
|
|
supabase.auth.onAuthStateChange(async (_event, _session) => {
|
|
const {
|
|
data: { claims },
|
|
} = await supabase.auth.getClaims()
|
|
if (claims) {
|
|
setUserId(claims.sub)
|
|
setEmail(claims.email)
|
|
} else {
|
|
setUserId(null)
|
|
setEmail(undefined)
|
|
}
|
|
})
|
|
}, [])
|
|
|
|
return <View>{userId ? <Account key={userId} userId={userId} email={email} /> : <Auth />}</View>
|
|
}
|