Changed type in views component

This commit is contained in:
r-freeman 2023-01-30 16:30:44 +00:00
parent de56c2aec7
commit 7170e786dd

View File

@ -3,7 +3,7 @@ import {ElementType, useEffect} from 'react'
import fetcher from '@/lib/fetcher' import fetcher from '@/lib/fetcher'
import {numberFormat} from '@/lib/numberFormat' import {numberFormat} from '@/lib/numberFormat'
type ViewsType = { type ViewsResponse = {
views: string views: string
} }
@ -17,7 +17,7 @@ type ViewsProps = {
const updateViews = (slug: string) => fetcher(`/api/views/${slug}`, {method: 'POST'}) const updateViews = (slug: string) => fetcher(`/api/views/${slug}`, {method: 'POST'})
export function Views({as: Component = 'span', slug, className, shouldUpdateViews = true}: ViewsProps) { export function Views({as: Component = 'span', slug, className, shouldUpdateViews = true}: ViewsProps) {
const {data} = useSWR<ViewsType>(`/api/views/${slug}`, fetcher, { const {data} = useSWR<ViewsResponse>(`/api/views/${slug}`, fetcher, {
revalidateOnFocus: false, revalidateOnFocus: false,
revalidateOnMount: true revalidateOnMount: true
}) })