You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/routes/solid-router/reference/data-apis/use-submissions.mdx
+19-13Lines changed: 19 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,8 @@ It's important to note that it requires the form method to be **post** otherwise
13
13
14
14
In the example below, the `useSubmissions` helper is used to retain a list of all submission results to that action while also giving feedback on the pending state of the current in-flight submission.
15
15
16
-
```tsx title="component.tsx" {4,9-15, 18}
16
+
```tsx title="component.tsx" {5,10-16, 19}
17
+
import { For, Show } from"solid-js";
17
18
import { useSubmissions } from"@solidjs/router";
18
19
19
20
function Component() {
@@ -47,7 +48,8 @@ As an optional second parameter, the `useSubmissions` helper can receive a filte
47
48
The filter receives the submitted data as a parameter and should return a boolean value.
48
49
The action below will only submit if the name is "solid".
49
50
50
-
```tsx title="component.tsx" {4-7}
51
+
```tsx title="component.tsx" {5-8}
52
+
import { For, Show } from"solid-js";
51
53
import { useSubmissions } from"@solidjs/router";
52
54
53
55
function Component() {
@@ -80,9 +82,8 @@ When the form is submitted, the `submission` object will be updated with the new
80
82
This allows you to provide feedback to the user that the action is in progress.
81
83
Once the action is complete, the `pending` property will be set to `false` and the `result` property will be updated with final value.
82
84
83
-
```tsx tab title="TypeScript" {6,13-20}
84
-
// component.tsx
85
-
import { Show } from"solid-js";
85
+
```tsx tab title="TypeScript" {5,12-17}
86
+
import { For, Show } from"solid-js";
86
87
import { useSubmissions } from"@solidjs/router";
87
88
88
89
function Component() {
@@ -93,8 +94,11 @@ function Component() {
93
94
<ul>
94
95
<Foreach={Array.from(submissions.entries())}>
95
96
{([, data]) => (
96
-
<Showwhen={data.input[0].entries().next()}keyed>
97
-
{(input) => <li>Optimistic: {input().value}</li>}
97
+
<Showwhen={data.input[0].entries().next()}>
98
+
{(input) => {
99
+
const name = (input().valueas [string, string])[1];
0 commit comments