This repository was archived by the owner on May 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,16 @@ const DetailGiftScreen = () => {
38
38
39
39
useEffect ( ( ) => {
40
40
const fetchRecipientName = async ( ) => {
41
- const name = await findRecipientById ( Number ( recipient ) ) ;
42
- setRecipientName ( name ) ;
41
+ try {
42
+ const recipientData = await findRecipientById ( Number ( recipient ) ) ;
43
+ if ( recipientData ) {
44
+ setRecipientName ( recipientData . name ) ;
45
+ } else {
46
+ console . error ( 'Recipient not found' ) ;
47
+ }
48
+ } catch ( error ) {
49
+ console . error ( 'Failed to fetch recipient name:' , error ) ;
50
+ }
43
51
} ;
44
52
45
53
fetchRecipientName ( ) ;
Original file line number Diff line number Diff line change @@ -78,10 +78,12 @@ const EditGiftScreen = () => {
78
78
if ( recipientData ) {
79
79
setRecipientName ( recipientData . name ) ;
80
80
} else {
81
- const fetchedRecipientName = await findRecipientById (
82
- Number ( recipient ) ,
83
- ) ;
84
- setRecipientName ( fetchedRecipientName ) ;
81
+ const fetchedRecipient = await findRecipientById ( Number ( recipient ) ) ;
82
+ if ( fetchedRecipient ) {
83
+ setRecipientName ( fetchedRecipient . name ) ;
84
+ } else {
85
+ console . error ( 'Recipient not found' ) ;
86
+ }
85
87
}
86
88
} catch ( error ) {
87
89
console . error ( 'Failed to fetch recipient name:' , error ) ;
You can’t perform that action at this time.
0 commit comments