import axios from 'axios' import { FunctionComponent } from 'react' import useSWR from 'swr' import FourOhFour from '../FourOhFour' import Loading from '../Loading' import DownloadBtn from '../DownloadBtn' const fetcher = (url: string) => axios.get(url).then(res => res.data) const TextPreview: FunctionComponent<{ file: any }> = ({ file }) => { const { data, error } = useSWR(file['@microsoft.graph.downloadUrl'], fetcher) if (error) { return (
) } if (!data) { return (
) } return ( <>
{data}
) } export default TextPreview