Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hola-soy-milk committed Feb 21, 2024
1 parent b5d8d54 commit 497d8b0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
16 changes: 10 additions & 6 deletions guest-list-mobile/app/guests/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ export default function Guests() {

useEffect(() => {
async function loadGuest() {
if (typeof id !== 'string') {
return;
try {
if (typeof id !== 'string') {
return;
}
const response = await fetch(`${API_URL}/guests/${id}`);
const fetchedGuest = await response.json();
setGuest(fetchedGuest);
} catch (error) {
console.error('Error fetching guest', error);
}
const response = await fetch(`${API_URL}/guests/${id}`);
const fetchedGuest = await response.json();
setGuest(fetchedGuest);
}
loadGuest();
loadGuest().catch(console.error);
}, [id]);

if (!guest) {
Expand Down
4 changes: 2 additions & 2 deletions guest-list-mobile/app/hello+api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ExpoRequest, ExpoResponse } from 'expo-router/server';
import { ExpoResponse } from 'expo-router/server';

export function GET(request: ExpoRequest) {
export function GET() {
return ExpoResponse.json({ hello: 'world' });
}
13 changes: 8 additions & 5 deletions guest-list-mobile/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,19 @@ export default function Index() {
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ firstName, lastName }),
body: JSON.stringify({
firstName: guest.firstName,
lastName: guest.lastName,
}),
});
const newGuest: Guest = await response.json();
setGuests([...guests, newGuest]);
setGuests((g) => [...g, newGuest]);
}
loadGuests();
callApi();
loadGuests().catch(console.error);
callApi().catch(console.error);

if (typeof firstName === 'string' && typeof lastName === 'string') {
postGuest({ firstName, lastName });
postGuest({ firstName, lastName }).catch(console.error);
}
}, [firstName, lastName]);
return (
Expand Down
8 changes: 4 additions & 4 deletions guest-list-mobile/app/new-guest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ const styles = StyleSheet.create({
});

export default function NewGuest() {
const [firstName, onFirstName] = useState('');
const [lastName, onLastName] = useState('');
const [firstName, setFirstName] = useState<string>('');
const [lastName, setLastName] = useState<string>('');
return (
<>
<TextInput
style={styles.input}
onChangeText={onFirstName}
onChangeText={setFirstName}
placeholder="First Name"
value={firstName}
/>
<TextInput
style={styles.input}
onChangeText={onLastName}
onChangeText={setLastName}
placeholder="Last Name"
value={lastName}
/>
Expand Down

0 comments on commit 497d8b0

Please sign in to comment.