navi
This commit is contained in:
34
src/components/MarkdownContent.js
Normal file
34
src/components/MarkdownContent.js
Normal file
@@ -0,0 +1,34 @@
|
||||
//src/components/MarkdownContent.js
|
||||
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
import {fetchWithCache} from "../utils/fetchWIthCache";
|
||||
|
||||
const MarkdownContent = () => {
|
||||
const { id } = useParams();
|
||||
const [content, setContent] = useState(null);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetchWithCache(`/api/markdown/${id}`)
|
||||
.then((data) => setContent(data))
|
||||
.catch((error) => setError(error));
|
||||
}, [id]);
|
||||
|
||||
if (error) {
|
||||
return <div>Error: {error}</div>;
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="markdown-content">
|
||||
<pre>{content}</pre>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MarkdownContent;
|
||||
Reference in New Issue
Block a user