Skip to content

Ahmad_Zetouny-w2-React #15

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Zetouny
Copy link

@Zetouny Zetouny commented Jun 26, 2025

@crevulus crevulus self-assigned this Jun 27, 2025
Copy link

@crevulus crevulus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ahmad,

Good work on this app - it looks great!

There are some things for you to work on, including code cleanup which is a very important part of keeping your codebase maintainable.

@@ -0,0 +1,6 @@
export default [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have missed a requirement from the README:

  • The fake-data directory should not be a part of your project anymore

🔴

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, I didn't delete the files. But it wasn't also used in the app

throw Error(`Couldn't fetch the data: ${response.status}`);
}

const date = await response.json();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this variable called date?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a typo. My bad! 😅

);

if (!response.ok) {
throw Error(`Couldn't fetch the data: ${response.status}`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to make your error message a little more user-friendly. The average user will not know what fetch means in this context, nor will they understand the 4xx or 5xx HTTP response code. 🔵


return (
<>
{error ? (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is called a nested ternary and it's generally not a great idea. Here's some info on conditional rendering in React: https://react.dev/learn/conditional-rendering 🟠

@@ -0,0 +1,5 @@
function Header({ title }) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a component is only rendering one JSX element with no extra logic it's not a useful component 🟠

try {
let url = "https://fakestoreapi.com/products";

if (filter != "") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use === for strict equality. This is more reliable than == (loose equality). https://www.freecodecamp.org/news/loose-vs-strict-equality-in-javascript/ 🔴

}, [filter]);

const productsList = products.map((product) => (
<NavLink className="product" key={product.id} to={`/product/${product.id}`}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import Header from "./components/Header.jsx";

function Product() {
let params = useParams();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params does not change value (& is not an array) so we should use const for our variable declaration here. 🔴

align-items: center;
justify-content: center;
gap: 2rem;
width: 70dvw;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what dvw does and why you need it here instead of vw?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dvw is more dynamic than vw, it calculates the actual viewport taking into concideration the browser UI

@Zetouny
Copy link
Author

Zetouny commented Jun 28, 2025

Thank you very much for your time Chris.
I've applied the changes as requested.

I'll make sure to improve them or/and try different techniques in the next week's assignment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants