@nkzw/fate-indexeddb 2.0.1 → 2.1.0
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 +23 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -759,6 +759,29 @@ fate.hydrate(loaderData.fate, { merge: 'replace' });
|
|
|
759
759
|
|
|
760
760
|
Snapshots from different hydration scopes cannot be combined. Keep each user's server client and snapshot separate.
|
|
761
761
|
|
|
762
|
+
#### Selective Hydration in React
|
|
763
|
+
|
|
764
|
+
If your server-rendered app uses Suspense boundaries that can hydrate at different times, pass the original snapshot to the React provider as well:
|
|
765
|
+
|
|
766
|
+
```tsx
|
|
767
|
+
const state = loaderData.fate;
|
|
768
|
+
const fate = createFateClient();
|
|
769
|
+
fate.hydrate(state);
|
|
770
|
+
|
|
771
|
+
hydrateRoot(
|
|
772
|
+
document,
|
|
773
|
+
<FateClient client={fate} hydrationState={state}>
|
|
774
|
+
<App />
|
|
775
|
+
</FateClient>,
|
|
776
|
+
);
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
If the live cache changes before a boundary hydrates, that boundary first reads the original snapshot to match its server HTML. Once it hydrates, it reads the live cache and applies any changes. Request policies that fetch from the network resume after the component hydrates.
|
|
780
|
+
|
|
781
|
+
Keep the same snapshot on the provider for the lifetime of the hydrated tree. The provider retains a separate copy of the server cache so delayed boundaries can still read it. This works with preloaded SSR data that covers the rendered content.
|
|
782
|
+
|
|
783
|
+
The snapshot applies to the React request and view hooks. If you pass an explicit client to a view hook, an enclosing provider for that client supplies its snapshot. Direct reads from the client or its store still read the live cache.
|
|
784
|
+
|
|
762
785
|
### Observing Request State
|
|
763
786
|
|
|
764
787
|
Outside React or Vue components, `fate.observeRequest(request, options)` provides request state through `getSnapshot()` and `subscribe(listener)`:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nkzw/fate-indexeddb",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Optional IndexedDB persistence adapter for fate.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"idb": "^8.0.4"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@nkzw/fate": "2.0
|
|
22
|
+
"@nkzw/fate": "2.1.0",
|
|
23
23
|
"fake-indexeddb": "^6.2.8",
|
|
24
24
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.6.0",
|
|
25
25
|
"vite-plus": "1.6.0"
|