meal_planner/src/containers/Category/index.tsx
Ruidy 8409d09373
refactoring (#6)
* 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
2021-03-29 12:37:53 +02:00

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} />
);
};