-
Notifications
You must be signed in to change notification settings - Fork 11
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
W3 aziz react #29
base: main
Are you sure you want to change the base?
W3 aziz react #29
Conversation
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.
Some changes, and I don't think I saw a link to a deployed version, is that correct?
week1/project/fakeshop/src/App.jsx
Outdated
const [selectedCategory, setSelectedCategory] = useState(null); // Başlangıçta kategori seçilmemiş | ||
|
||
// Kategori seçildiğinde ürünleri filtrele | ||
const handleCategoryClick = (category) => { |
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 do you need this function? It only calls one other function
<div className="category-list"> | ||
{categories.map((category, index) => ( | ||
<button key={index} onClick={() => { | ||
console.log("Category clicked: ", category); // Tıklanan kategoriyi kontrol edelim |
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.
Remove console logs from the code when creating a PR
<FavoritesProvider> | ||
<Router> | ||
<NavBar /> | ||
<Routes> |
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.
Clean, nice!
|
||
const ProductCard = memo(({ product }) => { | ||
const { favorites, toggleFavorite } = useFavorites(); | ||
const isFavorite = favorites.includes(product.id); |
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.
You are doing this in two places, maybe nicer to have the Favorites context provide this function?
dispatch({ type: "TOGGLE_FAVORITE", payload: id }); | ||
}; | ||
|
||
const value = useMemo( |
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 does this need to be memoized?
|
||
const initialState = []; | ||
|
||
const favoritesReducer = (state, action) => { |
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.
Little over the top to use a reducer here but cool that you are trying it!
|
||
useEffect(() => { | ||
const fetchFavorites = async () => { | ||
const fetchedProducts = await Promise.all( |
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.
Nice use of Promise.all!
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
No description provided.