@pylonsync/react 0.9.1 → 0.10.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/dist/ssr.d.ts +20 -0
- package/package.json +3 -3
- package/src/ssr.ts +20 -0
package/dist/ssr.d.ts
CHANGED
|
@@ -66,6 +66,26 @@ export interface SsrResponse {
|
|
|
66
66
|
* return <ul>{posts.map((p) => <li key={p.id}>{p.title}</li>)}</ul>;
|
|
67
67
|
* }
|
|
68
68
|
* ```
|
|
69
|
+
*
|
|
70
|
+
* Every method returns a thenable CACHED by (method, args), which is what
|
|
71
|
+
* makes `use()` stable across the replayed render — and already fulfilled on
|
|
72
|
+
* the client, so `use()` returns synchronously there.
|
|
73
|
+
*
|
|
74
|
+
* Reading several things: start every call BEFORE the first `use()`. Reading
|
|
75
|
+
* one at a time is correct but serial, since `use()` suspends on the first
|
|
76
|
+
* pending thenable.
|
|
77
|
+
*
|
|
78
|
+
* ```tsx
|
|
79
|
+
* const orgPromise = serverData.get<Org>("Org", auth.tenant_id);
|
|
80
|
+
* const postsPromise = serverData.list<Post>("Post");
|
|
81
|
+
* const org = use(orgPromise);
|
|
82
|
+
* const posts = use(postsPromise);
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* NEVER `use(Promise.all([...]))`. `Promise.all` returns a new, pending,
|
|
86
|
+
* uncached promise on every render, so `use()` suspends, React re-renders,
|
|
87
|
+
* builds another, and the component never returns — reported as an async
|
|
88
|
+
* Client Component (minified React error #482).
|
|
69
89
|
*/
|
|
70
90
|
export interface ServerData {
|
|
71
91
|
/** Get a single row by id. Resolves to null if not found. */
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.10.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"prepack": "bun run build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@pylonsync/sdk": "0.
|
|
18
|
-
"@pylonsync/sync": "0.
|
|
17
|
+
"@pylonsync/sdk": "0.10.0",
|
|
18
|
+
"@pylonsync/sync": "0.10.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": ">=19.0.0"
|
package/src/ssr.ts
CHANGED
|
@@ -85,6 +85,26 @@ export interface SsrResponse {
|
|
|
85
85
|
* return <ul>{posts.map((p) => <li key={p.id}>{p.title}</li>)}</ul>;
|
|
86
86
|
* }
|
|
87
87
|
* ```
|
|
88
|
+
*
|
|
89
|
+
* Every method returns a thenable CACHED by (method, args), which is what
|
|
90
|
+
* makes `use()` stable across the replayed render — and already fulfilled on
|
|
91
|
+
* the client, so `use()` returns synchronously there.
|
|
92
|
+
*
|
|
93
|
+
* Reading several things: start every call BEFORE the first `use()`. Reading
|
|
94
|
+
* one at a time is correct but serial, since `use()` suspends on the first
|
|
95
|
+
* pending thenable.
|
|
96
|
+
*
|
|
97
|
+
* ```tsx
|
|
98
|
+
* const orgPromise = serverData.get<Org>("Org", auth.tenant_id);
|
|
99
|
+
* const postsPromise = serverData.list<Post>("Post");
|
|
100
|
+
* const org = use(orgPromise);
|
|
101
|
+
* const posts = use(postsPromise);
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* NEVER `use(Promise.all([...]))`. `Promise.all` returns a new, pending,
|
|
105
|
+
* uncached promise on every render, so `use()` suspends, React re-renders,
|
|
106
|
+
* builds another, and the component never returns — reported as an async
|
|
107
|
+
* Client Component (minified React error #482).
|
|
88
108
|
*/
|
|
89
109
|
export interface ServerData {
|
|
90
110
|
/** Get a single row by id. Resolves to null if not found. */
|