-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (20 loc) · 756 Bytes
/
index.js
File metadata and controls
24 lines (20 loc) · 756 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
import React, { useEffect, useRef, useState } from "react";
import readingTime from "reading-time/lib/reading-time";
import { DocProvider } from "@docusaurus/plugin-content-docs/client";
import { DocContent } from "./DocContent";
function DocItem(props) {
const contentRef = useRef();
const [readingTimeInWords, setReadingTimeInWords] = useState("");
useEffect(() => {
if (contentRef.current) {
const readTime = readingTime(contentRef.current.innerText);
setReadingTimeInWords(readTime.text);
}
}, [contentRef]);
return (
<DocProvider content={props.content}>
<DocContent Content={props.content} contentRef={contentRef} readingTimeInWords={readingTimeInWords} />
</DocProvider>
);
}
export default DocItem;