-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
homework3 -class45-sanazzarei #37
base: main
Are you sure you want to change the base?
homework3 -class45-sanazzarei #37
Conversation
setFavorites([...favorites, productId]); | ||
} | ||
}; | ||
console.log(favorites); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be removed?
} | ||
|
||
if (error) { | ||
return <div>Sorry, we have an error: {error}</div>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job letting the user know about the error!
} catch (error) { | ||
console.error("Error:", error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think lines 18-19 already handle the error, you might not need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i thought response.ok checks if the HTTP request was successful, while the catch block handles any other potential errors during the process.
} | ||
|
||
const { data, isLoading, error } = useFetch(url); | ||
const products = data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the rename to products? If it's to make it more clear maybe the useFetch should export products instead of data. this is just a suggestion, no need to change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this folder can be removed
No description provided.