Skip to content

Commit 83f039a

Browse files
authored
Add useAction reference (#1011)
1 parent adad79a commit 83f039a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/routes/solid-router/reference/data-apis/data.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"create-async.mdx",
77
"create-async-store.mdx",
88
"query.mdx",
9+
"use-action.mdx",
910
"use-submission.mdx",
1011
"use-submissions.mdx"
1112
]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: useAction
3+
---
4+
5+
`useAction` allows an [`action`](/solid-router/reference/data-apis/action) to be invoked programmatically.
6+
7+
```tsx
8+
import { useAction } from "@solidjs/router";
9+
import { updateNameAction } from "./actions";
10+
11+
const updateName = useAction(updateNameAction);
12+
13+
const result = updateName("John Wick");
14+
```
15+
16+
<Callout type="info" title="Note">
17+
`useAction` requires client-side JavaScript and is not progressively
18+
enhanceable.
19+
</Callout>
20+
21+
## Parameters
22+
23+
- `action`: The action to be invoked.
24+
25+
## Returns
26+
27+
`useAction` returns a function that invokes the action.
28+
It shares the same signature as the action itself.

0 commit comments

Comments
 (0)