improved simple text opener
This commit is contained in:
parent
da85c3070c
commit
8ad319bc13
@ -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>
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user