@tinkered/react 0.25.1 → 0.26.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/package.json +3 -3
- package/skills/react/SKILL.md +42 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinkered/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Tinkered React: a thin React adapter over @tinkered/core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tanstack-intent"
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tinkered/core": "^0.
|
|
32
|
+
"@tinkered/core": "^0.26.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@stryker-mutator/core": "^10.0.0",
|
|
36
36
|
"@stryker-mutator/vitest-runner": "^10.0.0",
|
|
37
|
-
"@tinkered/core": "^0.
|
|
37
|
+
"@tinkered/core": "^0.26.0",
|
|
38
38
|
"@types/node": "^26.1.1",
|
|
39
39
|
"@types/react": "^19",
|
|
40
40
|
"@types/react-dom": "^19",
|
package/skills/react/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ description: >
|
|
|
5
5
|
component in a Tinker app: read a cell, run
|
|
6
6
|
an operation from a button, show a pending or
|
|
7
7
|
failed call, or mount the app. Also when a
|
|
8
|
-
check prints tinker/react-state,
|
|
8
|
+
check prints tinker/kind, tinker/react-state,
|
|
9
9
|
tinker/one-wire or tinker/keyed-prop.
|
|
10
10
|
metadata:
|
|
11
11
|
purpose: >
|
|
@@ -15,7 +15,7 @@ metadata:
|
|
|
15
15
|
type: framework
|
|
16
16
|
framework: react
|
|
17
17
|
library: '@tinkered/react'
|
|
18
|
-
library_version: '0.
|
|
18
|
+
library_version: '0.26.0'
|
|
19
19
|
requires:
|
|
20
20
|
- '@tinkered/core#core'
|
|
21
21
|
sources:
|
|
@@ -175,8 +175,46 @@ function Form() {
|
|
|
175
175
|
}
|
|
176
176
|
```
|
|
177
177
|
|
|
178
|
+
### Show each kind of an answer
|
|
179
|
+
|
|
180
|
+
A call can answer a union by `kind`. The page
|
|
181
|
+
reads it in a `switch` with a case for each kind,
|
|
182
|
+
and no `default`. A new kind in the contract then
|
|
183
|
+
fails the check at this `switch`.
|
|
184
|
+
|
|
185
|
+
```tsx no-check
|
|
186
|
+
function Moved({ out }: { out?: MoveAnswer }) {
|
|
187
|
+
switch (out?.kind) {
|
|
188
|
+
case undefined:
|
|
189
|
+
case "moved":
|
|
190
|
+
return null;
|
|
191
|
+
case "stale":
|
|
192
|
+
return <small role="status">Changed.</small>;
|
|
193
|
+
case "gone":
|
|
194
|
+
return <small role="status">Gone.</small>;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Read a field only in the case of a kind that has
|
|
200
|
+
it. `out.version` in case `gone` fails the type
|
|
201
|
+
check.
|
|
202
|
+
|
|
178
203
|
## Common mistakes
|
|
179
204
|
|
|
205
|
+
### HIGH: a kind with no case [tinker/kind]
|
|
206
|
+
|
|
207
|
+
Wrong:
|
|
208
|
+
|
|
209
|
+
```tsx no-check
|
|
210
|
+
if (out?.kind === "stale") return <Stale />;
|
|
211
|
+
return null;
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Right: a `switch` on `kind`, with a case for
|
|
215
|
+
each kind the check names. Do not add `default:`.
|
|
216
|
+
Do not cast.
|
|
217
|
+
|
|
180
218
|
### HIGH: `useState` or `useReducer` [tinker/react-state]
|
|
181
219
|
|
|
182
220
|
Wrong:
|
|
@@ -189,7 +227,7 @@ Right: a `data` cell, read with `useData`. For
|
|
|
189
227
|
state that must end with a subtree, put the
|
|
190
228
|
subtree in a `SessionProvider`.
|
|
191
229
|
|
|
192
|
-
### HIGH: `useEffect` [tinker/react-state]
|
|
230
|
+
### HIGH: `useEffect` or `useLayoutEffect` [tinker/react-state]
|
|
193
231
|
|
|
194
232
|
Wrong:
|
|
195
233
|
|
|
@@ -235,8 +273,6 @@ third argument.
|
|
|
235
273
|
|
|
236
274
|
## Completion
|
|
237
275
|
|
|
238
|
-
-
|
|
239
|
-
`tinker/react-state`, `tinker/one-wire` or
|
|
240
|
-
`tinker/keyed-prop`.
|
|
276
|
+
- `tinker check` prints `tinker check: OK`.
|
|
241
277
|
- A browser test clicks the control and reads
|
|
242
278
|
the new text.
|