Closed Kesmek closed 4 months ago
hi @Kesmek,
The useDatabase
hook works for both native SQLite (ExpoSqlite) and web (SQL.Js). However, the latter operates asynchronously due to the wasm
preloader steps.
As a solution, you can integrate a React component wrapper to verify the readiness of the database.
function ScreenPage() {
const {db} = useDatabase();
if(!db){
return <Loader/>
}
return <ScreentContent db={db} />
}
This step will be included in the ongoing code update.
Great, thanks for the suggested solution.
In the
src/index.tsx
file, you have auseLiveQuery
being used in conjuction with a database from theuseDatabase
hook:However the
useLiveQuery
hook doesn't accept a nullish database query, and gives the following error:The only way to use
useLiveQuery
as far as I know (without this error) is by directly accessing the db from drizzle:import {db} from "@/db/drizzle"
. I understand that using hooks to access the database is better practice but I can't figure out how to resolve this issue with the hooks. Any help would be appreciated.