-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useEffect executes many times during render when using options #1
Comments
@pocesar Can you post an example of how you implemented useMemo in this hook? Thank you. |
const settings = useMemo(() => {
return { enableHighAccuracy: true }
}, [])
const { latitude, longitude, timestamp, accuracy, error } = usePosition(true, settings) |
I'm having same issue. |
this prevents useEffect from running endlessly.
@trekhleb - Should we be using useSubscription here? See: https://github.com/facebook/react/pull/15022/files#diff-f3a2eff7618256a34a255026486e7e9fR7 |
Hey folks, it should be fixed now in |
@trekhleb I'm having this issue crop up in I'm fetching the geolocation using your tool for my weather app data, and it's repeatedly calling the api to fetch the weather. Thanks for creating this great tool. How would I reduce the number of times that I'm calling to the API? |
when using the second parameter, the
useEffect
gets called many times, leading to multiple calls to onChange, and multiple location changes, even if they aren't happening. either put on the readme that you need to pass anuseMemo
'ed options object or useMemo inside the hookThe text was updated successfully, but these errors were encountered: