improved simple text opener

This commit is contained in:
Djeeberjr 2021-08-06 21:52:19 +02:00
parent da85c3070c
commit 8ad319bc13

View File

@ -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<FileOpenerProps> = (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 (
<div>
<textarea>
{props.file.name}
</textarea>
<textarea value={text} readOnly/>
</div>
)
}