Skip to content

Commit 4126515

Browse files
committed
Merge branch 'react/suspense' of github.com:powersync-ja/powersync-js into react/suspense
2 parents 0b708c8 + 7921c71 commit 4126515

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

packages/react/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# React components for PowerSync
1+
# React Hooks for PowerSync
22

3-
## Context
3+
The `powersync/react` package provides React hooks for use with the JavaScript Web SDK or React Native SDK. These hooks are designed to support reactivity, and can be used to automatically re-render React components when query results update or to access PowerSync connectivity status changes.
4+
5+
## Usage
6+
7+
### Context
48

59
Configure a PowerSync DB connection and add it to a context provider.
610

@@ -63,9 +67,9 @@ const Component = () => {
6367
};
6468
```
6569

66-
## Queries
70+
## Reactive Queries
6771

68-
Queries will automatically update when a dependant table is updated unless you set the `runQueryOnce` flag. You are also able to use a compilable query (e.g. [Kysely queries](https://github.com/powersync-ja/powersync-js/tree/main/packages/kysely-driver)) as a query argument in place of a SQL statement string.
72+
The `useQuery` hook allows you to access the results of a watched query. Queries will automatically update when a dependant table is updated unless you set the `runQueryOnce` flag. You are also able to use a compilable query (e.g. [Kysely queries](https://github.com/powersync-ja/powersync-js/tree/main/packages/kysely-driver)) as a query argument in place of a SQL statement string.
6973

7074
```JSX
7175
// TodoListDisplay.jsx
@@ -119,8 +123,7 @@ export const TodoListsDisplayDemo = () => {
119123

120124
### Suspense
121125

122-
The `useSuspenseQuery` hook is available to handle the loading/fetching state through suspense.
123-
Unlike `useQuery`, the hook doesn't return `isLoading` or `isFetching` for the loading states nor `error` for the error state. These should be handled with variants of `<Suspense>` and `<ErrorBoundary>` respectively.
126+
The `useSuspenseQuery` hook also allows you to access the results of a watched query, but its loading and fetching states are handled through [Suspense](https://react.dev/reference/react/Suspense). Unlike `useQuery`, the hook doesn't return `isLoading` or `isFetching` for the loading states nor `error` for the error state. These should be handled with variants of `<Suspense>` and `<ErrorBoundary>` respectively.
124127

125128
```JSX
126129
// TodoListDisplaySuspense.jsx
@@ -154,7 +157,7 @@ export const TodoListDisplaySuspense = () => {
154157

155158
#### Blocking navigation on Suspense
156159

157-
When you provide a suspense fallback, suspending components will cause the fallback to render. Alternatively, React's [startTransition](https://react.dev/reference/react/startTransition) allows navigation to be blocked until the suspending components have completed, preventing the fallback from displaying. This behavior can be facilitated by your router — for example, react-router supports this with its [startTransition flag](https://reactrouter.com/en/main/upgrading/future#v7_starttransition).
160+
When you provide a Suspense fallback, suspending components will cause the fallback to render. Alternatively, React's [startTransition](https://react.dev/reference/react/startTransition) allows navigation to be blocked until the suspending components have completed, preventing the fallback from displaying. This behavior can be facilitated by your router — for example, react-router supports this with its [startTransition flag](https://reactrouter.com/en/main/upgrading/future#v7_starttransition).
158161

159162
> Note: In this example, the `<Suspense>` boundary is intentionally omitted to delegate the handling of the suspending state to the router.
160163

packages/vue/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Vue composables for PowerSync
22

3+
The `powersync/vue` package is a Vue-specific wrapper for PowerSync. It provides Vue composables that are designed to support reactivity, and can be used to automatically re-render components when query results update or to access PowerSync connectivity status changes.
4+
35
## Note: Beta Release
46

57
This package is currently in a beta release.
@@ -65,7 +67,7 @@ powersync.value.getAll('SELECT * from lists').then((l) => list.value = l);
6567
</template>
6668
```
6769

68-
## Query
70+
## Reactive Query
6971

7072
The `useQuery` composable provides a dynamic view of a given query. The data will automatically update when a dependent table is updated.
7173

0 commit comments

Comments
 (0)