electric-sql / electric-sql/pglite
React: Don't throw an error when `usePGlite()` doesn't find a PGlite instance
Open
- Dominant language
- TypeScript
- Stars
- 16k
- Forks
- 442
- Avg merge
- 20h 19m
- Merged PRs (30d)
- 7
Description
At the moment when PGlite is loading asynchronously, the UI has to wait. Otherwise anything using `usePGlite()` causes an error:
```
Uncaught Error: No PGlite instance found, use PGliteProvider to provide one
```
I can't easily wrap it in a try/catch because this is a hook.
Could `usePGlite()` just return `null` so the UI can handle around it until the DB loads?
Thanks!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.