diff --git a/src/components/TextOpener.tsx b/src/components/TextOpener.tsx index cd73130..02bc975 100644 --- a/src/components/TextOpener.tsx +++ b/src/components/TextOpener.tsx @@ -1,13 +1,24 @@ import React from "react" import PropTypes from "prop-types" import { FileOpenerProps } from "../types/FileOpenerProps" +import { useEffect } from "react" +import { useState } from "react" +import genDownloadLink from "../functions/genDownloadLink" const TextOpener: React.FC = (props) => { + + const [text,setText] = useState("") + + useEffect(()=>{ + if (props.active){ + fetch(genDownloadLink(props.file.id)).then((res)=>res.text()) + .then((result)=>setText(result)) + } + },[props.file]) + return (
- +