Skip to content

Commit

Permalink
fix(recipe-list.jsx): change initial value of reduce function from ob…
Browse files Browse the repository at this point in the history
…ject to array

The initial value of the reduce function was changed from an object to an array to fix a bug where
the function was not correctly accumulating values. A console.log was added to log the recipes data,
which will help in debugging and understanding the structure of the data.
  • Loading branch information
timDeHof committed Nov 10, 2023
1 parent ef1c17f commit d7de903
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/features/recipes/components/recipe-list/recipe-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const allowedTagTypes = [
export const RecipeList = ({ searchTerm }) => {
const prevTagsCollectionRef = useRef();
const { data: recipes, isLoading, isError, error } = FetchRecipes(searchTerm);
console.log(recipes);
const [selectedTags, setSelectedTags] = useState([]);
const [isOpen, setIsOpen] = useState(false);
// Initial tags collection state, derived from recipes
Expand Down Expand Up @@ -46,7 +47,7 @@ export const RecipeList = ({ searchTerm }) => {
}
});
return acc;
}, {});
}, []);

// Initialize the state with the allowed tag types only
const initializedTagsCollection = allowedTagTypes.reduce((acc, type) => {
Expand Down

0 comments on commit d7de903

Please sign in to comment.