updated NPED code
This commit is contained in:
42
src/context/providers/SightingFeedProvider.tsx
Normal file
42
src/context/providers/SightingFeedProvider.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { useSightingFeed } from "../../hooks/useSightingFeed";
|
||||
import { SightingFeedContext } from "../SightingFeedContext";
|
||||
|
||||
type SightingFeedProviderProps = {
|
||||
url: string;
|
||||
children: ReactNode;
|
||||
side: string;
|
||||
};
|
||||
|
||||
export const SightingFeedProvider = ({
|
||||
children,
|
||||
url,
|
||||
side,
|
||||
}: SightingFeedProviderProps) => {
|
||||
const {
|
||||
sightings,
|
||||
selectedRef,
|
||||
setSelectedRef,
|
||||
effectiveSelected,
|
||||
mostRecent,
|
||||
isPending,
|
||||
noSighting,
|
||||
} = useSightingFeed(url);
|
||||
|
||||
return (
|
||||
<SightingFeedContext.Provider
|
||||
value={{
|
||||
sightings,
|
||||
selectedRef,
|
||||
setSelectedRef,
|
||||
effectiveSelected,
|
||||
mostRecent,
|
||||
side,
|
||||
isPending,
|
||||
noSighting,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</SightingFeedContext.Provider>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user