diff --git a/src/tracking/TrackingManager.tsx b/src/tracking/TrackingManager.tsx index 3cd6d33..2d0841f 100644 --- a/src/tracking/TrackingManager.tsx +++ b/src/tracking/TrackingManager.tsx @@ -34,10 +34,30 @@ export function TrackingManager({children, service}: PropsWithChildren { + console.log("dispatch changed"); + }, [dispatch]); + + useEffect(() => { + console.log("service changed"); + }, [service]); + + useEffect(() => { + console.log("ids changed"); + }, [...ids]); + + useEffect(() => { + console.log("updatePositions changed"); + }, [updatePositions]); + /* Effect to defer a position update upon expiration of the tracking interval. */ const {nextUpdate} = state; + useEffect(() => { + console.log("nextUpdate changed"); + }, [nextUpdate]); useEffect(() => { const delay = nextUpdate.diff(DateTime.utc()).toMillis(); if (delay <= 0) { diff --git a/src/tracking/adsbx/ADSBXTrackingProvider.tsx b/src/tracking/adsbx/ADSBXTrackingProvider.tsx index 5825be4..bdb7485 100644 --- a/src/tracking/adsbx/ADSBXTrackingProvider.tsx +++ b/src/tracking/adsbx/ADSBXTrackingProvider.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import Axios, {AxiosHeaders, AxiosInstance, CreateAxiosDefaults} from "axios"; import {freeze} from "immer"; import _ from "lodash"; -import {PropsWithChildren, useMemo} from "react"; +import {PropsWithChildren, useEffect, useMemo} from "react"; import {TrackingManager} from "../TrackingManager"; import {ADSBXConfig} from "./ADSBX-types"; import {ADSBXClient} from "./ADSBXClient"; @@ -16,22 +16,25 @@ export interface ADSBXTrackingProviderProps extends ADSBXConfig { } export function ADSBXTrackingProvider({children, ...props}: PropsWithChildren) { - const {axiosFactory, auth, baseURL} = _.defaults({}, props, DEFAULT_PROPS); + const {axiosFactory, auth, baseURL: {href}} = _.defaults({}, props, DEFAULT_PROPS); const positionService = useMemo(() => { let headers = new AxiosHeaders().setAccept("application/json"); if (null != auth) { headers = headers.set("api-auth", auth); } - const axios = axiosFactory({ - baseURL: baseURL.href, + const axios = axiosFactory(freeze({ + baseURL: href, responseType: "json", headers: { common: headers } - }); + }, true)); const client = ADSBXClient.create(axios.request); return ADSBXPositionService.create(client); - }, [axiosFactory, auth, baseURL.href]); + }, [axiosFactory, auth, href]); + useEffect(() => { + console.log("positionService changed."); + }, [positionService]); return ( {children}