Skip to content

Alaa nasher w2 react#18

Open
Alaa2019-ml wants to merge 10 commits intoHackYourAssignment:mainfrom
Alaa2019-ml:Alaa_Nasher-w2-react
Open

Alaa nasher w2 react#18
Alaa2019-ml wants to merge 10 commits intoHackYourAssignment:mainfrom
Alaa2019-ml:Alaa_Nasher-w2-react

Conversation

@Alaa2019-ml
Copy link
Copy Markdown

crevulus and others added 9 commits June 19, 2025 11:32
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.2.11 to 5.4.6.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.4.6/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.4.6/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/braces@3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@crevulus crevulus self-assigned this Jan 3, 2026
@crevulus
Copy link
Copy Markdown

crevulus commented Jan 3, 2026

@Alaa2019-ml For week 3, please make sure you've checked out the latest version of the main branch. In your git history on this PR, I can see several old commits that were made by other contibutors (including me!)

Your PRs should encompass only your own new code.

Copy link
Copy Markdown

@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 Alaa,

Your app is working very well! Your code is a bit inconsistent - I've commented a few areas you could improve. Please see to those comments when you can.

export const fetchApi = async (url) => {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${res.status}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is res here?

const [error, setError] = useState(null);

useEffect(() => {
(async () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you explain why you have decided to use an IIFE here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I used an IIFE to keep the async logic scoped inside useEffect without creating a separate function that would only be called once.

return (
<>
<h1>{product.title}</h1>
<img src={product.image} alt={product.title} style={{ width: 200 }} />
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use either inline styles or css stylesheets - not both! Consistency makes it easier for your colleagues to understand your code.

Comment thread week2/project/ecommerce/src/App.jsx Outdated
import { Routes, Route } from "react-router-dom";

function App() {
const [productsToShow, filterProductsToShow] = useState(null);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Make sure to follow the useState naming convention: stateVariable, and setStateVariable. You have some state variables in several files that don't follow this convention. Following conventions will help your colleagues undertand your code better.

Comment thread week2/project/ecommerce/src/App.jsx Outdated
path="/"
element={
<>
<h1>Products:</h1>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Storing route components inline will become very messy very quickly. Imagine you have 15 routes, and you add them all inline like this one. This file would very quickly become several hundred lines long and become difficult to manage. The dedciated component you've created for ProductDetails is a good pattern to follow.

@Alaa2019-ml
Copy link
Copy Markdown
Author

@Alaa2019-ml
Copy link
Copy Markdown
Author

I have updated the code. Thank you

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.

3 participants