fpcourse/components/LessonContainer.tsx
2023-04-14 15:36:03 -05:00

21 lines
460 B
TypeScript

import useSWR from "swr";
import ReactMarkdown from "react-markdown";
const fetcher = (...args) => fetch(...args).then((res) => res.json());
const LessonContainer = ({ name }) => {
const { data, error, isLoading } = useSWR(
`/api/lesson?name=${name}`,
fetcher
);
return (
<>
<h1>Lesson about {name}</h1>
{!isLoading && !error && <ReactMarkdown>{data.contents}</ReactMarkdown>}
</>
);
};
export default LessonContainer;