improved simple text opener
This commit is contained in:
parent
da85c3070c
commit
8ad319bc13
@ -1,13 +1,24 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { FileOpenerProps } from "../types/FileOpenerProps"
|
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 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 (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<textarea>
|
<textarea value={text} readOnly/>
|
||||||
{props.file.name}
|
|
||||||
</textarea>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user