From 41c68b15132476ce275ac9948fed295fa44be8db Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 4 Dec 2025 09:55:46 -0600 Subject: [PATCH] Use useEffect for side effect --- src/geolocation/index.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/geolocation/index.tsx b/src/geolocation/index.tsx index 06d386750b..953205619f 100644 --- a/src/geolocation/index.tsx +++ b/src/geolocation/index.tsx @@ -1,4 +1,10 @@ -import {createContext, type ReactNode, useContext, useMemo} from 'react' +import { + createContext, + type ReactNode, + useContext, + useEffect, + useMemo, +} from 'react' import {useSyncDeviceGeolocationOnStartup} from '#/geolocation/device' import {useGeolocationServiceResponse} from '#/geolocation/service' @@ -35,11 +41,13 @@ export function Provider({children}: {children: ReactNode}) { 'deviceGeolocation', ]) const geolocation = useMemo(() => { - const merged = mergeGeolocations(deviceGeolocation, geolocationService) - device.set(['mergedGeolocation'], merged) - return merged + return mergeGeolocations(deviceGeolocation, geolocationService) }, [deviceGeolocation, geolocationService]) + useEffect(() => { + device.set(['mergedGeolocation'], geolocation) + }, [geolocation]) + useSyncDeviceGeolocationOnStartup(setDeviceGeolocation) return (