mirror of
https://github.com/rjNemo/meal_planner
synced 2026-06-06 02:26:49 +00:00
* use tsx * compile * refactor Router * refactor layout * refactor home container * refactor meal container * refactor categories container * refactor category container * refactor search and profile container * refactor * move state over * move state over * css * css
20 lines
596 B
TypeScript
20 lines
596 B
TypeScript
import { FC, useEffect, useState } from "react";
|
|
import { Redirect, useParams } from "react-router-dom";
|
|
import { getData } from "../../services/api";
|
|
import { CategoryPage } from "./components/CategoryPage";
|
|
|
|
export const Category: FC = () => {
|
|
const { strCategory } = useParams();
|
|
const [meals, setMeals] = useState({ meals: [] });
|
|
|
|
useEffect(() => {
|
|
const getMeals = () => getData(strCategory, setMeals, "filter");
|
|
getMeals();
|
|
}, [strCategory]);
|
|
|
|
return !meals.meals ? (
|
|
<Redirect to="/404" />
|
|
) : (
|
|
<CategoryPage meals={meals} strCategory={strCategory} />
|
|
);
|
|
};
|