fixed type errors
This commit is contained in:
@@ -1,19 +1,16 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { SightingType, SightingWidgetType } from "../types/types";
|
||||
import type { SightingType } from "../types/types";
|
||||
|
||||
async function fetchSighting(
|
||||
url: string,
|
||||
ref: number
|
||||
): Promise<SightingWidgetType> {
|
||||
async function fetchSighting(url: string, ref: number): Promise<SightingType> {
|
||||
const res = await fetch(`${url}${ref}`);
|
||||
if (!res.ok) throw new Error(String(res.status));
|
||||
return await res.json();
|
||||
}
|
||||
|
||||
export function useSightingFeed(url: string) {
|
||||
const [sightings, setSightings] = useState<SightingWidgetType[]>([]);
|
||||
const [sightings, setSightings] = useState<SightingType[]>([]);
|
||||
const [selectedRef, setSelectedRef] = useState<number | null>(null);
|
||||
const [mostRecent, setMostRecent] = useState<SightingWidgetType | null>(null);
|
||||
const [mostRecent, setMostRecent] = useState<SightingType | null>(null);
|
||||
const [selectedSighting, setSelectedSighting] = useState<SightingType | null>(
|
||||
null
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user