-
Notifications
You must be signed in to change notification settings - Fork 12
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
Bug: Renders indefinetly when using a callback function #58
Comments
Hi @2Up1Down 👋 Thank you for flagging this. In the implementation there is a I recommend you wrap your callback function within a If you could kindly confirm that this resolves your issue, I would be very happy to update the documentation accordingly. |
Hi @bence-toth I updated my code with a useCallback and this seems working. However I'm not the biggest fan of this approach. Maybe there is a more elegant solution to it. But then.. I consider myself still a beginner in React.,. My question to you:
Do you really need the callback in the dependency array? |
When using the useGeolocation hook it renders indefinitely when using the optional callback function. See the example below:
https://codesandbox.io/s/nextjs-geolocation-b3defn?file=/pages/react-hook-geolocation.js
When the optional callback function is set to null its working fine.
Is this an expected behaviour?
The text was updated successfully, but these errors were encountered: