electric-sql / electric-sql/pglite

React: Don't throw an error when `usePGlite()` doesn't find a PGlite instance

Open
#878 1 comment 0 reactions 0 assignees View on GitHub
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.