@electric-sql/react 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Electric provides an HTTP interface to Postgres to enable massive number of clie
|
|
|
6
6
|
|
|
7
7
|
This packages exposes a `useShape` hook for pulling shape data into your React components.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`Shapes` and `ShapeStreams` instances are cached globally so re-using shapes in multiple components is cheap.
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -14,19 +14,9 @@ The `ShapesProvider` caches shapes globally so re-using shapes in multiple compo
|
|
|
14
14
|
|
|
15
15
|
## How to use
|
|
16
16
|
|
|
17
|
-
Add the Shapes provider
|
|
18
|
-
```tsx
|
|
19
|
-
import { ShapesProvider } from "@electric-sql/react"
|
|
20
|
-
|
|
21
|
-
ReactDOM.createRoot(document.getElementById(`root`)!).render(
|
|
22
|
-
<ShapesProvider>
|
|
23
|
-
<App />
|
|
24
|
-
</ShapesProvider>
|
|
25
|
-
)
|
|
26
|
-
```
|
|
27
|
-
|
|
28
17
|
Add `useShape` to a component
|
|
29
|
-
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
30
20
|
import { useShape } from "@electric-sql/react"
|
|
31
21
|
|
|
32
22
|
export default function MyComponent () {
|
|
@@ -37,7 +27,7 @@ export default function MyComponent () {
|
|
|
37
27
|
if (!isUpToDate) {
|
|
38
28
|
return <div>loading</div>
|
|
39
29
|
}
|
|
40
|
-
|
|
30
|
+
|
|
41
31
|
return (
|
|
42
32
|
<div>
|
|
43
33
|
{data.map(foo => <div>{foo.title}</div>)}
|