-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuoteDetail.js
More file actions
30 lines (24 loc) · 793 Bytes
/
QuoteDetail.js
File metadata and controls
30 lines (24 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { useParams, Route } from "react-router-dom";
import { Fragment } from "react";
import Comments from "../components/comments/Comments";
import HighlightedQuote from "../components/quotes/HighlightedQuote";
const DUMMY_QUOTES = [
{ id: "q1", author: "Max", text: "Learning React is Fun" },
{ id: "q2", author: "John", text: "Learning ML is Fun" },
];
const QuoteDetail = () => {
const params = useParams();
const quote = DUMMY_QUOTES.find((quote) => quote.id === params.quoteId);
if (!quote) {
return <p>No quote Found</p>;
}
return (
<Fragment>
<HighlightedQuote text={quote.text} author={quote.author} />
<Route path={`/quotes/${params.quoteId}/comments`}>
<Comments />
</Route>
</Fragment>
);
};
export default QuoteDetail;