Skip to content

Commit

Permalink
Remove state
Browse files Browse the repository at this point in the history
  • Loading branch information
ProchaLu committed Oct 31, 2024
1 parent 08b0b42 commit 185bb63
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions app/(tabs)/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { router, useFocusEffect } from 'expo-router';
import React, { useCallback, useState } from 'react';
import React, { useCallback } from 'react';
import { Alert, Pressable, StyleSheet, Text, View } from 'react-native';
import { colors } from '../../constants/colors';
import type { LogoutResponseBodyGet } from '../api/logout+api';
Expand Down Expand Up @@ -37,8 +37,6 @@ const styles = StyleSheet.create({
});

export default function ProfileScreen() {
const [user, setUser] = useState();

useFocusEffect(
useCallback(() => {
async function getUser() {

Check warning on line 42 in app/(tabs)/profile.tsx

View workflow job for this annotation

GitHub Actions / Type Checking, Linting

'getUser' is defined but never used
Expand All @@ -48,20 +46,13 @@ export default function ProfileScreen() {

if ('error' in body) {
Alert.alert('Error', body.error, [{ text: 'OK' }]);
return;
return router.push('/(auth)');
}

if (!body) {
router.push('/(auth)');
return;
}

setUser(body);
getUser().catch((error) => {
console.error(error);
});
}

getUser().catch((error) => {
console.error(error);
});
}, []),
);

Expand Down

0 comments on commit 185bb63

Please sign in to comment.