chore(SW-3665): Upgrade to Next 16 * Upgrade partner-sas * Upgrade scandic-web to next 16 * Update peerDep versions * Fix revalidateTag * Remove comment * Merge branch 'master' into chore/upgrade-to-next16 * Update netlify adapter * Build with webpack instead of turbopack * Revert from proxy to middleware * Merge branch 'master' into chore/upgrade-to-next16 * Revert proxy type * Fix react types versions * 16.0.9 * Bump to 16.0.10 Approved-by: Linus Flood
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
"use client"
|
|
import { useSearchParams } from "next/navigation"
|
|
import { useRef } from "react"
|
|
|
|
import { createHotelListingDataStore } from "@/stores/hotel-listing-data"
|
|
|
|
import { HotelListingDataContext } from "@/contexts/HotelListingData"
|
|
|
|
import HotelListingDataProviderContent from "./Content"
|
|
|
|
import type { HotelListingDataStore } from "@/types/contexts/hotel-listing-data"
|
|
import type { HotelListingDataProviderProps } from "@/types/providers/hotel-listing-data"
|
|
|
|
export default function HotelListingDataProvider({
|
|
allHotels,
|
|
allFilters,
|
|
sortItems,
|
|
children,
|
|
}: HotelListingDataProviderProps) {
|
|
const storeRef = useRef<HotelListingDataStore>(undefined)
|
|
const searchParams = useSearchParams()
|
|
|
|
// eslint-disable-next-line react-hooks/refs
|
|
if (!storeRef.current) {
|
|
storeRef.current = createHotelListingDataStore({
|
|
allHotels,
|
|
allFilters,
|
|
sortItems,
|
|
searchParams,
|
|
})
|
|
}
|
|
|
|
return (
|
|
// eslint-disable-next-line react-hooks/refs
|
|
<HotelListingDataContext.Provider value={storeRef.current}>
|
|
<HotelListingDataProviderContent>
|
|
{children}
|
|
</HotelListingDataProviderContent>
|
|
</HotelListingDataContext.Provider>
|
|
)
|
|
}
|