[solved] useLiveQuery seems to always run the query twice
I'm using drizzle-orm in an expo app and it seems to me (with logging turned on) every instance of
useLiveQuery
causes the query to happen twice in quick succession. Why is this?5 Replies
This may not be it, but just an idea: if you are using react in development mode with strict mode enabled (which is often the default) hooks are run twice / components are rendered twice. You could make a prod build and see if the behavior continues to determine if this is the cause or not. Looks like in expo there is a flag to temporarily disable dev mode
Expo Documentation
Development and production modes
Learn how to run a project in development mode or production mode.
thank you, I had no idea dev mode rendered or ran hooks twice. This page here doesn't explicitly mention that though, where is this mentioned in the docs?
Mentioned in the behaviors list below the second code block https://react.dev/reference/react/StrictMode
– React
The library for web and native user interfaces
thank you! this really explains things 😅 sorry for what appears to be a react-n00b question
No worries