useSWR instead of custom useAxiosGet hook for cache reuse

This commit is contained in:
spencerwooo
2022-01-24 20:50:43 +08:00
parent 17263feea9
commit b47dd88d1a
7 changed files with 18 additions and 26 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ import DownloadButtonGroup from '../DownloadBtnGtoup'
import { DownloadBtnContainer, PreviewContainer } from './Containers'
const CodePreview: FC<{ file: any }> = ({ file }) => {
const { content, error, validating } = useAxiosGet(file['@microsoft.graph.downloadUrl'])
const { response: content, error, validating } = useAxiosGet(file['@microsoft.graph.downloadUrl'])
useEffect(() => {
if (typeof window !== 'undefined') {
+1 -1
View File
@@ -19,7 +19,7 @@ const MarkdownPreview: FC<{ file: any; path: string; standalone?: boolean }> = (
path,
standalone = true,
}) => {
const { content, error, validating } = useAxiosGet(file['@microsoft.graph.downloadUrl'])
const { response: content, error, validating } = useAxiosGet(file['@microsoft.graph.downloadUrl'])
// The parent folder of the markdown file, which is also the relative image folder
const parentPath = path.substring(0, path.lastIndexOf('/'))
+1 -1
View File
@@ -5,7 +5,7 @@ import useAxiosGet from '../../utils/fetchOnMount'
import { DownloadBtnContainer, PreviewContainer } from './Containers'
const TextPreview = ({ file }) => {
const { content, error, validating } = useAxiosGet(file['@microsoft.graph.downloadUrl'])
const { response: content, error, validating } = useAxiosGet(file['@microsoft.graph.downloadUrl'])
if (error) {
return (
<PreviewContainer>
+1 -1
View File
@@ -12,7 +12,7 @@ const parseDotUrl = (content: string): string | undefined => {
}
const TextPreview = ({ file }) => {
const { content, error, validating } = useAxiosGet(file['@microsoft.graph.downloadUrl'])
const { response: content, error, validating } = useAxiosGet(file['@microsoft.graph.downloadUrl'])
if (error) {
return (
<PreviewContainer>